diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-01-20 13:57:29 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-01-20 13:57:29 +0000 |
commit | 5741d007f66028b89c577fd24fc43feacb33d373 (patch) | |
tree | 97d390f32b534301999ceaf0574661743fd9afb7 | |
parent | e355a55e3c691399cf120e3e21815c8ea623dae9 (diff) | |
download | redmine-5741d007f66028b89c577fd24fc43feacb33d373.tar.gz redmine-5741d007f66028b89c577fd24fc43feacb33d373.zip |
Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11222 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/user.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 10ed38c78..e4b54dc41 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -353,13 +353,16 @@ 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) - # First look for an exact match - user = where(:login => login).all.detect {|u| u.login == login} - unless user - # Fail over to case-insensitive if none was found - user = where("LOWER(login) = ?", login.to_s.downcase).first + if login.present? + login = login.to_s + # First look for an exact match + user = where(:login => login).all.detect {|u| u.login == login} + unless user + # Fail over to case-insensitive if none was found + user = where("LOWER(login) = ?", login.downcase).first + end + user end - user end def self.find_by_rss_key(key) |