Code cleanup.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11375 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2013-02-14 22:13:49 +00:00
parent 812da860b3
commit 3c3ac3c6ee
1 changed files with 4 additions and 10 deletions

View File

@ -156,19 +156,13 @@ class User < Principal
login = login.to_s login = login.to_s
password = password.to_s password = password.to_s
# Make sure no one can sign in with an empty password # Make sure no one can sign in with an empty login or password
return nil if password.empty? return nil if login.empty? || password.empty?
user = find_by_login(login) user = find_by_login(login)
if user if user
# user is already in local database # user is already in local database
return nil if !user.active? return nil unless user.active?
if user.auth_source return nil unless user.check_password?(password)
# user has an external authentication method
return nil unless user.auth_source.authenticate(login, password)
else
# authentication with local password
return nil unless user.check_password?(password)
end
else else
# user is not yet registered, try to authenticate with available sources # user is not yet registered, try to authenticate with available sources
attrs = AuthSource.authenticate(login, password) attrs = AuthSource.authenticate(login, password)