]> projects.mako.cc - selectricity-live/blob - app/controllers/voter_controller.rb
Added the forgot password functionality to the voters of Full Elections. Also, modifi...
[selectricity-live] / app / controllers / voter_controller.rb
1 class VoterController < ApplicationController
2   layout 'main'
3   require_dependency "voter"
4   require_dependency "vote"
5   require_dependency "election"
6
7   def index
8     password = params[:id]
9     password = params[:vote][:password] if params[:vote]
10     if @voter = FullVoter.find(:all, :conditions => [ "password = ?", password ] )[0]
11       @voter.vote = Vote.new if @voter.vote.nil?
12       @voter.vote.set_defaults! if @voter.vote.rankings.empty?
13       render :action => 'full_vote'
14     end
15   end
16   
17   def review
18     if authenticate
19       @voter.vote.time = Time.now
20       @voter.vote.save
21       @voter.reload
22     else
23       redirect_to :action => 'index'
24     end
25   end
26
27   def confirm
28     if authenticate
29       @voter.vote.confirm!
30       render :action => 'thanks'
31     else
32       redirect_to :action => 'index'
33     end
34   end
35   
36   private
37   def authenticate
38     password = params[:id]
39     @voter = FullVoter.find(:all, :conditions => [ "password = ?", password ] )[0]
40   end
41 end
42

Benjamin Mako Hill || Want to submit a patch?