X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/fc0a6a8d7ea15bcdb27ebdd58721401c7045c6e0..94f498a0718776efa90193c918c6dd22f51329ac:/app/models/full_voter.rb?ds=sidebyside diff --git a/app/models/full_voter.rb b/app/models/full_voter.rb old mode 100755 new mode 100644 index 04071a0..b82667c --- a/app/models/full_voter.rb +++ b/app/models/full_voter.rb @@ -5,8 +5,16 @@ class FullVoter < Voter def create_password token_generator = UniqueTokenGenerator.new( 16 ) until password and not password.empty? \ - and Voter.find_all( [ "password = ?", password ]).empty? + and Voter.find(:all, :conditions => [ "password = ?", password ]).empty? self.password = token_generator.token end end + + protected + def validate + # E-mail regex, moderate complexity + # Stolen from http://www.regular-expressions.info/email.html + errors.add(:email, "is not valid") unless email =~ + /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i + end end