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