Implements the behaviour expected in user_test.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9029 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-02-28 05:46:33 +00:00
parent c0048f7954
commit df3c2466f8
1 changed files with 2 additions and 1 deletions

View File

@ -132,7 +132,8 @@ class User < Principal
def self.try_to_login(login, password)
# Make sure no one can sign in with an empty password
return nil if password.to_s.empty?
user = find_by_login(login)
matches = find_all_by_login(login)
user = (matches.size < 2 ? matches.first : matches.detect {|u| u.login == login})
if user
# user is already in local database
return nil if !user.active?