##// END OF EJS Templates
Force string comparison for login search to be case sensitive on MySQL. #2473...
Eric Davis -
r3699:672852baafdd
parent child
Show More
@@ -225,10 +225,13 class User < Principal
225 # Find a user account by matching the exact login and then a case-insensitive
225 # Find a user account by matching the exact login and then a case-insensitive
226 # version. Exact matches will be given priority.
226 # version. Exact matches will be given priority.
227 def self.find_by_login(login)
227 def self.find_by_login(login)
228 # force string comparison to be case sensitive on MySQL
229 type_cast = (ActiveRecord::Base.connection.adapter_name == 'MySQL') ? 'BINARY' : ''
230
228 # First look for an exact match
231 # First look for an exact match
229 user = first(:conditions => {:login => login})
232 user = first(:conditions => ["#{type_cast} login = ?", login])
230 # Fail over to case-insensitive if none was found
233 # Fail over to case-insensitive if none was found
231 user ||= first(:conditions => ["LOWER(login) = ?", login.to_s.downcase])
234 user ||= first(:conditions => ["#{type_cast} LOWER(login) = ?", login.to_s.downcase])
232 end
235 end
233
236
234 def self.find_by_rss_key(key)
237 def self.find_by_rss_key(key)
General Comments 0
You need to be logged in to leave comments. Login now