登录名区分大小写

This commit is contained in:
z9hang 2014-07-01 17:12:48 +08:00
parent 37acecae61
commit d34ab220cc
1 changed files with 5 additions and 4 deletions

View File

@ -577,15 +577,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.
#通过用户名查找相应的用户,若没有匹配到,则不区分大小写进行查询
#修改:不再匹配不区分大小写情况 -zjc
def self.find_by_login(login)
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
#unless user
# # Fail over to case-insensitive if none was found
# user = where("LOWER(login) = ?", login.downcase).first
#end
user
end
end