Force downcase on usernames

This commit is contained in:
Raphael 2010-09-13 14:48:55 -07:00
parent f6b6720349
commit fd31e9aeeb

View file

@ -29,10 +29,13 @@ class User
before_validation_on_create :setup_person
before_validation :do_bad_things
before_save :downcase_username
def self.find_for_authentication(conditions={})
if conditions[:username] =~ /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i # email regex
conditions[:email] = conditions.delete(:username)
else
conditions[:username].downcase!
end
super
end
@ -303,6 +306,9 @@ class User
self.person.save!
end
def downcase_username
username.downcase!
end
def as_json(opts={})