X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/c65b1e11059c5cf510b54c785d4a246215058f70..8964e46880760a85a7c86a239f032c841a96410d:/app/models/full_voter.rb diff --git a/app/models/full_voter.rb b/app/models/full_voter.rb index 04071a0..b82667c 100644 --- 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