Commit a6b5dfe60d1ecd1e4025467ee0cfdcf7886232fe
1 parent
b5ecb6a4
Exists in
master
and in
29 other branches
Normalize email before save
Showing
2 changed files
with
17 additions
and
0 deletions
Show diff stats
app/models/user.rb
... | ... | @@ -98,6 +98,7 @@ class User < ActiveRecord::Base |
98 | 98 | validates_length_of :email, :within => 3..100, :if => (lambda {|user| !user.email.blank?}) |
99 | 99 | validates_uniqueness_of :login, :email, :case_sensitive => false, :scope => :environment_id |
100 | 100 | before_save :encrypt_password |
101 | + before_save :normalize_email | |
101 | 102 | validates_format_of :email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda {|user| !user.email.blank?}) |
102 | 103 | |
103 | 104 | validates_inclusion_of :terms_accepted, :in => [ '1' ], :if => lambda { |u| ! u.terms_of_use.blank? }, :message => N_('{fn} must be checked in order to signup.').fix_i18n |
... | ... | @@ -328,6 +329,11 @@ class User < ActiveRecord::Base |
328 | 329 | end |
329 | 330 | |
330 | 331 | protected |
332 | + | |
333 | + def normalize_email | |
334 | + self.email = self.email.squish.downcase | |
335 | + end | |
336 | + | |
331 | 337 | # before filter |
332 | 338 | def encrypt_password |
333 | 339 | return if password.blank? | ... | ... |