1 class FullVoter < Voter
2 validates_presence_of :email, :password
4 def initialize(params={})
10 token_generator = UniqueTokenGenerator.new( 16 )
11 until password and not password.empty? \
12 and Voter.find(:all, :conditions => [ "password = ?", password ]).empty?
13 self.password = token_generator.token
19 # E-mail regex, moderate complexity
20 # Stolen from http://www.regular-expressions.info/email.html
21 errors.add(:email, "is not valid") unless email =~
22 /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i