Strip leading and trailing whitespace for email authentication
Fixes #2173
This commit is contained in:
parent
b7834aa827
commit
e174eb762f
1 changed files with 2 additions and 2 deletions
|
@ -122,10 +122,10 @@ class User < ActiveRecord::Base
|
|||
|
||||
def self.authenticate(options)
|
||||
if options[:username] && options[:password]
|
||||
user = find_by("email = ? OR display_name = ?", options[:username], options[:username])
|
||||
user = find_by("email = ? OR display_name = ?", options[:username].strip, options[:username])
|
||||
|
||||
if user.nil?
|
||||
users = where("LOWER(email) = LOWER(?) OR LOWER(display_name) = LOWER(?)", options[:username], options[:username])
|
||||
users = where("LOWER(email) = LOWER(?) OR LOWER(display_name) = LOWER(?)", options[:username].strip, options[:username])
|
||||
|
||||
user = users.first if users.count == 1
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue