@@ -132,8 +132,7 class User < Principal | |||||
132 | def self.try_to_login(login, password) |
|
132 | def self.try_to_login(login, password) | |
133 | # Make sure no one can sign in with an empty password |
|
133 | # Make sure no one can sign in with an empty password | |
134 | return nil if password.to_s.empty? |
|
134 | return nil if password.to_s.empty? | |
135 |
|
|
135 | user = find_by_login(login) | |
136 | user = (matches.size < 2 ? matches.first : matches.detect {|u| u.login == login}) |
|
|||
137 | if user |
|
136 | if user | |
138 | # user is already in local database |
|
137 | # user is already in local database | |
139 | return nil if !user.active? |
|
138 | return nil if !user.active? | |
@@ -325,13 +324,13 class User < Principal | |||||
325 | # Find a user account by matching the exact login and then a case-insensitive |
|
324 | # Find a user account by matching the exact login and then a case-insensitive | |
326 | # version. Exact matches will be given priority. |
|
325 | # version. Exact matches will be given priority. | |
327 | def self.find_by_login(login) |
|
326 | def self.find_by_login(login) | |
328 | # force string comparison to be case sensitive on MySQL |
|
|||
329 | type_cast = (ActiveRecord::Base.connection.adapter_name == 'MySQL') ? 'BINARY' : '' |
|
|||
330 |
|
||||
331 | # First look for an exact match |
|
327 | # First look for an exact match | |
332 | user = first(:conditions => ["#{type_cast} login = ?", login]) |
|
328 | user = all(:conditions => {:login => login}).detect {|u| u.login == login} | |
333 | # Fail over to case-insensitive if none was found |
|
329 | unless user | |
334 | user ||= first(:conditions => ["#{type_cast} LOWER(login) = ?", login.to_s.downcase]) |
|
330 | # Fail over to case-insensitive if none was found | |
|
331 | user = first(:conditions => ["LOWER(login) = ?", login.to_s.downcase]) | |||
|
332 | end | |||
|
333 | user | |||
335 | end |
|
334 | end | |
336 |
|
335 | |||
337 | def self.find_by_rss_key(key) |
|
336 | def self.find_by_rss_key(key) |
General Comments 0
You need to be logged in to leave comments.
Login now