Allow multiple authentication_keys on login#1004
Allow multiple authentication_keys on login#1004danielneis wants to merge 7 commits intolynndylanhurley:masterfrom
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 |
| conditions = [] | ||
| values = {} | ||
| fields.each do |f| | ||
| q = " #{f.to_s} = :#{f.to_s} " |
There was a problem hiding this comment.
use more meaningful variables, maybe query_field ?
There was a problem hiding this comment.
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 |
|
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