From: Tom Hughes Date: Fri, 8 Mar 2019 10:58:42 +0000 (+0000) Subject: Strip leading and trailing whitespace for email authentication X-Git-Tag: live~3248 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/e174eb762f7552de34b6fbdedf2fc12b50c464f5?ds=inline;hp=--cc Strip leading and trailing whitespace for email authentication Fixes #2173 --- e174eb762f7552de34b6fbdedf2fc12b50c464f5 diff --git a/app/models/user.rb b/app/models/user.rb index 27ed7b648..25947a96f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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