summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-28 06:27:23 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-28 06:27:23 +0000
commite1d1a3a0c2e5472271d16b84b5580863d1adffab (patch)
tree1d93b4fda9aadf2c630b88ace8e73a8cdd9ef7c1 /app/models
parentdf3c2466f8ca1af5e97eb5f92e10e2d5f20e2a2c (diff)
downloadredmine-e1d1a3a0c2e5472271d16b84b5580863d1adffab.tar.gz
redmine-e1d1a3a0c2e5472271d16b84b5580863d1adffab.zip
Fixes r9029.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9030 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/user.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 9ac5a4fd0..15cdce1b2 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -132,8 +132,7 @@ 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?
- matches = find_all_by_login(login)
- user = (matches.size < 2 ? matches.first : matches.detect {|u| u.login == login})
+ user = find_by_login(login)
if user
# user is already in local database
return nil if !user.active?
@@ -325,13 +324,13 @@ class User < Principal
# Find a user account by matching the exact login and then a case-insensitive
# version. Exact matches will be given priority.
def self.find_by_login(login)
- # force string comparison to be case sensitive on MySQL
- type_cast = (ActiveRecord::Base.connection.adapter_name == 'MySQL') ? 'BINARY' : ''
-
# First look for an exact match
- user = first(:conditions => ["#{type_cast} login = ?", login])
- # Fail over to case-insensitive if none was found
- user ||= first(:conditions => ["#{type_cast} LOWER(login) = ?", login.to_s.downcase])
+ user = all(:conditions => {:login => login}).detect {|u| u.login == login}
+ unless user
+ # Fail over to case-insensitive if none was found
+ user = first(:conditions => ["LOWER(login) = ?", login.to_s.downcase])
+ end
+ user
end
def self.find_by_rss_key(key)