devise

https://github.com/plataformatec/devise

Ruby

Flexible authentication solution for Rails with Warden.

Devise::Models::Authenticatable::ClassMethods#find_for_authentication

Find first record based on conditions given (ie by the sign in form).
This method is always called during an authentication process but
it may be wrapped as well. For instance, database authenticatable
provides a `find_for_database_authentication` that wraps a call to
this method. This allows you to customize both database authenticatable
or the whole authenticate stack by customize `find_for_authentication.`

Overwrite to add customized conditions, create a join, or maybe use a
namedscope to filter records while authenticating.
Example:

  def self.find_for_authentication(tainted_conditions)
    find_first_by_auth_conditions(tainted_conditions, active: true)
  end

Finally, notice that Devise also queries for users in other scenarios
besides authentication, for example when retrieving an user to send
an e-mail for password reset. In such cases, find_for_authentication
is not called.

Source | Google | Stack overflow

Edit

git clone [email protected]:plataformatec/devise.git

cd devise

open lib/devise/models/authenticatable.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Devise--Models--Authenticatable--ClassMethods-find_for_authentication-for-pr


# Commit to git

git add lib/devise/models/authenticatable.rbgit commit -m "better docs for Devise::Models::Authenticatable::ClassMethods#find_for_authentication"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Devise--Models--Authenticatable--ClassMethods-find_for_authentication-for-pr

hub pull-request


# Celebrate!