Skip to content

Commit

Permalink
added ability to get password emailed to self at submission time
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Adida authored and Ben Adida committed May 27, 2009
1 parent f6f2ca3 commit b606de5
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 5 deletions.
32 changes: 31 additions & 1 deletion controllers/election.py
Expand Up @@ -101,7 +101,7 @@ def add(self, email, name, category=None):
v.insert()

raise cherrypy.HTTPRedirect("../voters_manage")

@web
def submit(self, voter, email, password, encrypted_vote):
"""
Expand Down Expand Up @@ -441,7 +441,37 @@ def voters_bulk_upload(self, election, voters_csv):

return self.redirect("./voters_manage")

@web
def send_password(self, election, email):
"""
send a copy of the password
"""

election_obj = election.toElection()

voter = do.Voter.selectByEmailOrOpenID(election, email, None)
if not voter:
return "no such voter"

# send a confirmation email
mail_body = """
Dear %s,
You requested a copy of your election password for election %s. It is:
%s
And, as a reminder, the fingerprint of the election itself is:
%s
--
The Helios Voting System
""" % (voter.name, election_obj.name, voter.password, election_obj.hash)

mail.simple_send([voter.name],[voter.email], "Helios", "ben@adida.net", "password reminder", mail_body)

return SUCCESS

@web
def open_submit(self, election, encrypted_vote, email=None, openid_url=None, name=None, category=None):
"""
Expand Down
4 changes: 2 additions & 2 deletions index.yaml
Expand Up @@ -17,7 +17,7 @@ indexes:
- name: exponent
direction: desc

# Used 6 times in query history.
# Used 5 times in query history.
- kind: KeyShare
properties:
- name: election
Expand All @@ -43,7 +43,7 @@ indexes:
- name: tallied_at
- name: cast_id

# Used 9 times in query history.
# Used 8 times in query history.
- kind: Voter
properties:
- name: election
Expand Down
4 changes: 3 additions & 1 deletion static/templates/booth/login.html
Expand Up @@ -18,7 +18,9 @@ <h3 style="border-bottom: 1px solid black;">Submit Your Encrypted Ballot</h3>

<form onsubmit="BOOTH.send_ballot(); return false;" action="#" id="send_ballot_form" class="prettyform">
<label for="email">Email:</label>
<input type="text" name="email" size="30" /><br />
<input type="text" name="email" size="30" />
(<a href="javascript:BOOTH.get_password();">get password</a>)
<br />
<label for="password">Password:</label>
<input type="password" name="password" size="30" /><br/>
<label for="submit">&nbsp;</label>
Expand Down
19 changes: 18 additions & 1 deletion templates/election/vote.tmpl
Expand Up @@ -244,7 +244,24 @@ BOOTH.send_ballot_raw = function() {
};

BOOTH.send_ballot = function() {
BOOTH.show_processing_before("BOOTH.send_ballot_raw()");
BOOTH.show_processing_before("BOOTH.send_ballot_raw()");
};

BOOTH.get_password = function() {
var send_form = document.forms['send_ballot_form'];

var data = {
email : send_form.email.value
};

\$.ajax({
type: "POST",
url: "/elections/$election.election_id/send_password",
data: data,
success: function(result) {
alert('password should be in your inbox');
}
});
};

BOOTH.show_receipt = function() {
Expand Down

0 comments on commit b606de5

Please sign in to comment.