@@ -353,13 +353,16 class User < Principal | |||||
353 | # Find a user account by matching the exact login and then a case-insensitive |
|
353 | # Find a user account by matching the exact login and then a case-insensitive | |
354 | # version. Exact matches will be given priority. |
|
354 | # version. Exact matches will be given priority. | |
355 | def self.find_by_login(login) |
|
355 | def self.find_by_login(login) | |
356 | # First look for an exact match |
|
356 | if login.present? | |
357 | user = where(:login => login).all.detect {|u| u.login == login} |
|
357 | login = login.to_s | |
358 | unless user |
|
358 | # First look for an exact match | |
359 | # Fail over to case-insensitive if none was found |
|
359 | user = where(:login => login).all.detect {|u| u.login == login} | |
360 | user = where("LOWER(login) = ?", login.to_s.downcase).first |
|
360 | unless user | |
|
361 | # Fail over to case-insensitive if none was found | |||
|
362 | user = where("LOWER(login) = ?", login.downcase).first | |||
|
363 | end | |||
|
364 | user | |||
361 | end |
|
365 | end | |
362 | user |
|
|||
363 | end |
|
366 | end | |
364 |
|
367 | |||
365 | def self.find_by_rss_key(key) |
|
368 | def self.find_by_rss_key(key) |
General Comments 0
You need to be logged in to leave comments.
Login now