Skip to content

Commit a32fa2a

Browse files
author
Irene
committed
Authenticate user with email if username not found
1 parent 665f130 commit a32fa2a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

app/models/user.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def has_password?(submitted_password)
123123
end
124124

125125
def self.authenticate(login, submitted_password)
126-
user = find_by_login(login)
126+
user = find_by(login: login)
127+
user = find_by(email: login) if user.nil?
127128
return nil if user.nil?
128129
return user if user.has_password?(submitted_password)
129130
end

0 commit comments

Comments
 (0)