1 class FullVoter < Voter
2 before_create :create_password
3 validates_presence_of :email, :password
6 token_generator = UniqueTokenGenerator.new( 16 )
7 until password and not password.empty? \
8 and Voter.find(:all, :conditions => [ "password = ?", password ]).empty?
9 self.password = token_generator.token
15 # E-mail regex, moderate complexity
16 # Stolen from http://www.regular-expressions.info/email.html
17 errors.add(:email, "is not valid") unless email =~
18 /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i