Refactor and documentation for User#find_by_login.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3808 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
de17640489
commit
6cb4ff7d89
|
@ -222,13 +222,13 @@ class User < Principal
|
||||||
notified_projects_ids
|
notified_projects_ids
|
||||||
end
|
end
|
||||||
|
|
||||||
# case-insensitive fall-over
|
# 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)
|
def self.find_by_login(login)
|
||||||
# First look for an exact match
|
# First look for an exact match
|
||||||
user = find(:first, :conditions => ["login = ?", login])
|
user = first(:conditions => {:login => login})
|
||||||
# Fail over to case-insensitive if none was found
|
# Fail over to case-insensitive if none was found
|
||||||
user = find(:first, :conditions => ["LOWER(login) = ?", login.to_s.downcase]) if user.nil?
|
user ||= first(:conditions => ["LOWER(login) = ?", login.to_s.downcase])
|
||||||
return user
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find_by_rss_key(key)
|
def self.find_by_rss_key(key)
|
||||||
|
|
Loading…
Reference in New Issue