]> git.openstreetmap.org Git - rails.git/commitdiff
Strip leading and trailing whitespace for email authentication
authorTom Hughes <tom@compton.nu>
Fri, 8 Mar 2019 10:58:42 +0000 (10:58 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 8 Mar 2019 10:59:57 +0000 (10:59 +0000)
Fixes #2173

app/models/user.rb

index 27ed7b648cb3e0bb7864d37d4f4180a3b5f0ef43..25947a96f66082875830c5f0c946415e11902367 100644 (file)
@@ -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