]> source.dussan.org Git - redmine.git/commitdiff
Implements the behaviour expected in user_test.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 28 Feb 2012 05:46:33 +0000 (05:46 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 28 Feb 2012 05:46:33 +0000 (05:46 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9029 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/user.rb

index 9b0ab81104a05583b7da4708f460ee7216f7ee83..9ac5a4fd022707c4814a20f2bb29540b27b36c34 100644 (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?