Skip to content
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

Support for find_for_database_authentication #1138

Closed
fameoflight opened this issue Apr 9, 2018 · 1 comment
Closed

Support for find_for_database_authentication #1138

fameoflight opened this issue Apr 9, 2018 · 1 comment

Comments

@fameoflight
Copy link

Devise use find_for_database_authentication for finding the user which make it easy to support additional attributes like if we want to have single login field when I am using username and emails.

Would be great if token auth used find_for_database_authentication rather than doing it's own find.

@lynndylanhurley Let me know if you are open to it I will send in a pull request

in the meantime, if anyone else is looking to do the same, here is a quick hack overriding wherein User model.


def self.where(*args)
    # override for devise-token auth
    if args.length == 2 && args[0] == "login = ? AND provider='email'"
      where(['lower(username) = :value OR lower(email) = :value', { value: args[1] }])
    else
      super
    end
  end

@MaicolBen
Copy link
Collaborator

Check #1004

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants