X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/5a8b533b5abec8dc24674e4ef084b0b9779da8af..9abed97635edbac7fb1a687298fff5c5434cdff4:/app/controllers/elections_controller.rb diff --git a/app/controllers/elections_controller.rb b/app/controllers/elections_controller.rb index 696028e..b3406a8 100644 --- a/app/controllers/elections_controller.rb +++ b/app/controllers/elections_controller.rb @@ -1,3 +1,5 @@ +require 'uniq_token' + class ElectionsController < ApplicationController model :raw_voter_list, :voter, :vote, :candidate @@ -104,10 +106,17 @@ class ElectionsController < ApplicationController def process_incoming_voters(raw_voter_list) incoming_voters = RawVoterList.new( raw_voter_list ) + token_generator = UniqueTokenGenerator.new( 16 ) unless incoming_voters.entries.empty? incoming_voters.each do |new_voter| + until new_voter.password and \ + Voter.find_all( [ "password = ?", new_voter.password ]).empty? + new_voter.password = token_generator.token + end + + breakpoint if incoming_voters.email == 0 new_voter.contacted = 1 elsif incoming_voters.email == 1 @@ -127,4 +136,8 @@ class ElectionsController < ApplicationController @raw_voter_list = RawVoterList.new @raw_voter_list.email = incoming_voters.email end + + def email_voter + end + end