From: Jean-Philippe Lang Date: Tue, 28 Feb 2012 05:46:33 +0000 (+0000) Subject: Implements the behaviour expected in user_test. X-Git-Tag: 1.4.0~285 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=df3c2466f8ca1af5e97eb5f92e10e2d5f20e2a2c;p=redmine.git Implements the behaviour expected in user_test. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9029 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/user.rb b/app/models/user.rb index 9b0ab8110..9ac5a4fd0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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?