1 # Selectricity: Voting Machinery for the Masses
2 # Copyright (C) 2007, 2008 Benjamin Mako Hill <mako@atdot.cc>
3 # Copyright (C) 2007 Massachusetts Institute of Technology
5 # This program is free software. Please see the COPYING file for
8 class FullVoter < Voter
9 validates_presence_of :email, :password
11 def initialize(params={})
17 token_generator = UniqueTokenGenerator.new( 16 )
18 until password and not password.empty? \
19 and Voter.find(:all, :conditions => [ "password = ?", password ]).empty?
20 self.password = token_generator.token
26 # E-mail regex, moderate complexity
27 # Stolen from http://www.regular-expressions.info/email.html
28 errors.add(:email, "is not valid") unless email =~
29 /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i