X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/6cde8c9b0c4220db3b5598a268c197e77258a8cc..e174eb762f7552de34b6fbdedf2fc12b50c464f5:/app/models/user.rb diff --git a/app/models/user.rb b/app/models/user.rb index 17985e05f..25947a96f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -93,11 +93,9 @@ class User < ActiveRecord::Base validates :display_name, :if => proc { |u| u.display_name_changed? }, :uniqueness => { :case_sensitive => false } validates :display_name, :if => proc { |u| u.display_name_changed? }, - :invalid_chars => true, - :invalid_url_chars => true, - :leading_whitespace => true, - :trailing_whitespace => true - validates :email, :presence => true, :confirmation => true, :invalid_chars => true + :characters => { :url_safe => true }, + :whitespace => { :leading => false, :trailing => false } + validates :email, :presence => true, :confirmation => true, :characters => true validates :email, :if => proc { |u| u.email_changed? }, :uniqueness => { :case_sensitive => false } validates :pass_crypt, :confirmation => true, :length => 8..255 @@ -124,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