Skip to content

Support for find_for_database_authenticationΒ #1138

@fameoflight

Description

@fameoflight

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions