removes else case

This commit is contained in:
Juanjo Bazán
2017-06-13 12:22:48 +02:00
parent c4ba6a7e94
commit 2f895d2f6b

View File

@@ -291,12 +291,9 @@ class User < ActiveRecord::Base
# overwritting of Devise method to allow login using email OR username # overwritting of Devise method to allow login using email OR username
def self.find_for_database_authentication(warden_conditions) def self.find_for_database_authentication(warden_conditions)
conditions = warden_conditions.dup conditions = warden_conditions.dup
if login = conditions.delete(:login) login = conditions.delete(:login)
where(conditions.to_hash).where(["lower(email) = ?", login.downcase]).first || where(conditions.to_hash).where(["lower(email) = ?", login.downcase]).first ||
where(conditions.to_hash).where(["username = ?", login]).first where(conditions.to_hash).where(["username = ?", login]).first
elsif conditions.has_key?(:username) || conditions.has_key?(:email)
where(conditions.to_hash).first
end
end end
private private