]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user.rb
Strip leading and trailing whitespace for email authentication
[rails.git] / 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