Skip to content

Instantly share code, notes, and snippets.

@rodloboz
Last active May 8, 2019 22:38
Show Gist options
  • Save rodloboz/f0381defb4ff4f6c32bcbf92e5713c79 to your computer and use it in GitHub Desktop.
Save rodloboz/f0381defb4ff4f6c32bcbf92e5713c79 to your computer and use it in GitHub Desktop.
# app/models/user.rb
def self.find_for_database_authentication(warden_conditions)
conditions = warden_conditions.dup
login = conditions.delete(:login)
where(conditions).where(["lower(username) = :value OR lower(email) = :value", {value: login.strip.downcase}]).first
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment