##// END OF EJS Templates
Refactor and documentation for User#find_by_login....
Eric Davis -
r3694:6cb4ff7d8981
parent child
Show More
@@ -221,14 +221,14 class User < Principal
221 @notified_projects_ids = nil
221 @notified_projects_ids = nil
222 notified_projects_ids
222 notified_projects_ids
223 end
223 end
224
224
225 # case-insensitive fall-over
225 # Find a user account by matching the exact login and then a case-insensitive
226 # version. Exact matches will be given priority.
226 def self.find_by_login(login)
227 def self.find_by_login(login)
227 # First look for an exact match
228 # First look for an exact match
228 user = find(:first, :conditions => ["login = ?", login])
229 user = first(:conditions => {:login => login})
229 # Fail over to case-insensitive if none was found
230 # Fail over to case-insensitive if none was found
230 user = find(:first, :conditions => ["LOWER(login) = ?", login.to_s.downcase]) if user.nil?
231 user ||= first(:conditions => ["LOWER(login) = ?", login.to_s.downcase])
231 return user
232 end
232 end
233
233
234 def self.find_by_rss_key(key)
234 def self.find_by_rss_key(key)
General Comments 0
You need to be logged in to leave comments. Login now