Commit d6f14613666b7eab79eae8116a7cb208ca11e1e2
Exists in
staging
and in
42 other branches
Merge remote-tracking branch 'origin/master'
Showing
2 changed files
with
17 additions
and
0 deletions
Show diff stats
app/models/user.rb
| @@ -102,6 +102,7 @@ class User < ActiveRecord::Base | @@ -102,6 +102,7 @@ class User < ActiveRecord::Base | ||
| 102 | validates_length_of :email, :within => 3..100, :if => (lambda {|user| !user.email.blank?}) | 102 | validates_length_of :email, :within => 3..100, :if => (lambda {|user| !user.email.blank?}) |
| 103 | validates_uniqueness_of :login, :email, :case_sensitive => false, :scope => :environment_id | 103 | validates_uniqueness_of :login, :email, :case_sensitive => false, :scope => :environment_id |
| 104 | before_save :encrypt_password | 104 | before_save :encrypt_password |
| 105 | + before_save :normalize_email | ||
| 105 | validates_format_of :email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda {|user| !user.email.blank?}) | 106 | validates_format_of :email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda {|user| !user.email.blank?}) |
| 106 | 107 | ||
| 107 | 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 | 108 | 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 |
| @@ -336,6 +337,11 @@ class User < ActiveRecord::Base | @@ -336,6 +337,11 @@ class User < ActiveRecord::Base | ||
| 336 | end | 337 | end |
| 337 | 338 | ||
| 338 | protected | 339 | protected |
| 340 | + | ||
| 341 | + def normalize_email | ||
| 342 | + self.email = self.email.squish.downcase | ||
| 343 | + end | ||
| 344 | + | ||
| 339 | # before filter | 345 | # before filter |
| 340 | def encrypt_password | 346 | def encrypt_password |
| 341 | return if password.blank? | 347 | return if password.blank? |