Fixes r9029.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9030 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
df3c2466f8
commit
e1d1a3a0c2
|
@ -132,8 +132,7 @@ class User < Principal
|
||||||
def self.try_to_login(login, password)
|
def self.try_to_login(login, password)
|
||||||
# Make sure no one can sign in with an empty password
|
# Make sure no one can sign in with an empty password
|
||||||
return nil if password.to_s.empty?
|
return nil if password.to_s.empty?
|
||||||
matches = find_all_by_login(login)
|
user = find_by_login(login)
|
||||||
user = (matches.size < 2 ? matches.first : matches.detect {|u| u.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 if !user.active?
|
||||||
|
@ -325,13 +324,13 @@ class User < Principal
|
||||||
# Find a user account by matching the exact login and then a case-insensitive
|
# Find a user account by matching the exact login and then a case-insensitive
|
||||||
# version. Exact matches will be given priority.
|
# version. Exact matches will be given priority.
|
||||||
def self.find_by_login(login)
|
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
|
# First look for an exact match
|
||||||
user = first(:conditions => ["#{type_cast} login = ?", login])
|
user = all(:conditions => {:login => login}).detect {|u| u.login == login}
|
||||||
# Fail over to case-insensitive if none was found
|
unless user
|
||||||
user ||= first(:conditions => ["#{type_cast} LOWER(login) = ?", login.to_s.downcase])
|
# Fail over to case-insensitive if none was found
|
||||||
|
user = first(:conditions => ["LOWER(login) = ?", login.to_s.downcase])
|
||||||
|
end
|
||||||
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find_by_rss_key(key)
|
def self.find_by_rss_key(key)
|
||||||
|
|
Loading…
Reference in New Issue