-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow multiple authentication_keys on login #1004
base: master
Are you sure you want to change the base?
Conversation
Hey @danielneis looks like the build is failing - could you perhaps better explain what your pull request is doing? I read through it but I'm not sure if I understand. Thanks for taking the time! |
Hi, @zachfeldman , what I am trying to do is to use all the resource_class.authentication_keys instead of only the first one. The users in my database uses two fields for authentication (account and agency, for example). |
Got it @danielneis - well if the checks pass I'd be down to merge, I don't see a huge problem with that. |
You didn't define For the next time, please put a PR here when the work is finished. |
28a06ce
to
49d67a4
Compare
49d67a4
to
567f792
Compare
Now the tests are passing =) It would be nice to have some tests for those cases with multiple :authentication_keys |
Awesome! Sorry for the delay. You can add tests with different keys in https://github.com/lynndylanhurley/devise_token_auth/blob/master/test/controllers/devise_token_auth/sessions_controller_test.rb#L18 |
Isn't this branch merged yet? Can you please write a guide on how to use this new feature? Thank you in advance |
Hello, if you have on your devise configuration something like that:
Then you will have on your User model something like:
This will use the two fields for comparison when logging someone in. The account and domain must match. With this patch, it will also work with devise_token_auth =) |
Sounds good! thanks, this resolves #1128 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests?
conditions = [] | ||
values = {} | ||
fields.each do |f| | ||
q = " #{f.to_s} = :#{f.to_s} " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use more meaningful variables, maybe query_field
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure! just did it. called q = condition and f = field.
conditions.push(' provider = :provider') | ||
values[:provider] = provider.to_s | ||
|
||
@resource = resource_class.where([conditions.join(" AND "), values]).first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use single quotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure! just did it.
I took a look at the current tests and I'm afraid I don't know where to begin. |
@danielneis @MaicolBen will this be resolved anytime soon? |
Hello,
this is second attempt of #949
I rebased the patch to current master and added back the "binary" statement for mysql