Skip to content

Commit c148a3d

Browse files
authored
Merge pull request #480 from testmycode/email-auth
Authenticate user with email if username not found
2 parents 665f130 + a32fa2a commit c148a3d

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)