module Devise::Models::DatabaseAuthenticatable::ClassMethods

def authenticate(attributes={})

authenticated user if it's valid or nil.
Authenticate a user based on configured attribute keys. Returns the
def authenticate(attributes={})
  return unless authentication_keys.all? { |k| attributes[k].present? }
  conditions = attributes.slice(*authentication_keys)
  resource = find_for_authentication(conditions)
  resource if resource.try(:valid_for_authentication?, attributes)
end