diff --git a/build_js.sh b/build_js.sh
index fc765ab..535e25d 100755
--- a/build_js.sh
+++ b/build_js.sh
@@ -38,6 +38,7 @@ for f in eos.js_tests; do
# Transcrypt bug
perl -0777 -pi -e 's/property.call \((.*?), \g1.\g1.__impl__(.*?)\)/property.call ($1, $1.__impl__$2)/g' eos/__javascript__/$f.js
+ perl -0777 -pi -e 's/property.call \((.*?), \g1.\g1.__implpy_(.*?)\)/property.call ($1, $1.__impl__$2)/g' eos/__javascript__/$f.js
done
cp eos/__javascript__/eos.js_tests.js eosweb/core/static/js/eosjs.js
diff --git a/eos/base/election.py b/eos/base/election.py
index 0d7bc7e..7738e3f 100644
--- a/eos/base/election.py
+++ b/eos/base/election.py
@@ -41,11 +41,17 @@ class Vote(EmbeddedObject):
class Voter(EmbeddedObject):
_id = UUIDField()
- name = StringField()
votes = EmbeddedObjectListField()
-class EmailVoter(Voter):
- email = StringField()
+class User(EmbeddedObject):
+ pass
+
+class UserVoter(Voter):
+ user = EmbeddedObjectField()
+
+ @property
+ def name(self):
+ return self.user.name
class Question(EmbeddedObject):
prompt = StringField()
diff --git a/eos/js.py b/eos/js.py
index 17eaf9f..56608db 100644
--- a/eos/js.py
+++ b/eos/js.py
@@ -26,3 +26,5 @@ import eos.psr.crypto
import eos.psr.election
import eos.psr.mixnet
import eos.psr.workflow
+
+import eos.redditauth.election
diff --git a/eos/redditauth/__init__.py b/eos/redditauth/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/eos/redditauth/election.py b/eos/redditauth/election.py
new file mode 100644
index 0000000..4c3790e
--- /dev/null
+++ b/eos/redditauth/election.py
@@ -0,0 +1,31 @@
+# Eos - Verifiable elections
+# Copyright © 2017 RunasSudo (Yingtong Li)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+
+from eos.base.election import *
+from eos.core.objects import *
+
+class RedditUser(User):
+ oauth_token = StringField(is_protected=True)
+ username = StringField()
+
+ @property
+ def name(self):
+ return self.username
+
+ def matched_by(self, other):
+ if not isinstance(other, RedditUser):
+ return False
+ return other.username == self.username
diff --git a/eosweb/core/main.py b/eosweb/core/main.py
index 6cf2546..ff7b0cd 100644
--- a/eosweb/core/main.py
+++ b/eosweb/core/main.py
@@ -92,11 +92,8 @@ def setup_test_election():
# Set election details
election.name = 'Test Election'
- voter = Voter()
- election.voters.append(Voter(name='Alice'))
- election.voters.append(Voter(name='Bob'))
- election.voters.append(Voter(name='Charlie'))
- election.voters.append(Voter(name='RunasSudo'))
+ from eos.redditauth.election import RedditUser
+ election.voters.append(UserVoter(user=RedditUser(username='RunasSudo')))
election.mixing_trustees.append(InternalMixingTrustee(name='Eos Voting'))
election.mixing_trustees.append(InternalMixingTrustee(name='Eos Voting'))
@@ -207,7 +204,7 @@ def election_api_cast_vote(election):
voter = None
for election_voter in election.voters:
- if election_voter.name == flask.session['user'].username:
+ if election_voter.user.matched_by(flask.session['user']):
voter = election_voter
break
@@ -223,8 +220,8 @@ def election_api_cast_vote(election):
election.save()
return flask.Response(json.dumps({
- 'voter': EosObject.serialise_and_wrap(voter),
- 'vote': EosObject.serialise_and_wrap(vote)
+ 'voter': EosObject.serialise_and_wrap(voter, should_protect=True),
+ 'vote': EosObject.serialise_and_wrap(vote, should_protect=True)
}), mimetype='application/json')
@app.route('/debug')
diff --git a/eosweb/core/static/nunjucks/booth/cast.html b/eosweb/core/static/nunjucks/booth/cast.html
index c4ecc44..e50dccc 100644
--- a/eosweb/core/static/nunjucks/booth/cast.html
+++ b/eosweb/core/static/nunjucks/booth/cast.html
@@ -24,9 +24,9 @@
This election requires you to log in to vote. If you disconnected your internet connection earlier, you must now reconnect it before proceeding.
{% if username %}
- You are currently logged in as {{ username }}. Please select an option from the list below if you would like to switch accounts. Otherwise, click ‘Cast ballot’ to continue.
+ You are currently logged in as {{ username }}. Please select an option from the list below if you would like to switch accounts. Otherwise, click ‘Cast ballot’ to continue.
{% else %}
- You are not currently logged in. Please select an option from the list below to log in. Your ballot will be automatically cast once you have logged in.
+ You are not currently logged in. Please select an option from the list below to log in. Your ballot will be automatically cast once you have logged in.
{% endif %}
@@ -69,6 +69,7 @@
}
function callback_complete() {
$("#cast_button").removeClass("hidden");
+ $("#booth_logged_in_as").text("You are currently logged in.");
castBallot();
}
@@ -101,7 +102,11 @@
$("#error_unknown").addClass("hidden");
} else {
- $("#error_unknown_tech").text("Technical details: " + err + " – " + xhr.responseText);
+ if (xhr.responseText && xhr.responseText.length < 100) {
+ $("#error_unknown_tech").text("Technical details: " + err + " – " + xhr.responseText);
+ } else {
+ $("#error_unknown_tech").text("Technical details: " + err);
+ }
$("#error_unknown").removeClass("hidden");
$("#error_invalid_id").addClass("hidden");
@@ -110,6 +115,7 @@
$("#casting").hide();
$("#cast_prompt").show();
+ console.error(xhr);
throw err;
});
}
diff --git a/eosweb/core/templates/auth/login_cancelled.html b/eosweb/core/templates/auth/login_cancelled.html
new file mode 100644
index 0000000..e200a94
--- /dev/null
+++ b/eosweb/core/templates/auth/login_cancelled.html
@@ -0,0 +1,33 @@
+{% extends 'semantic_base.html' %}
+
+{#
+ Eos - Verifiable elections
+ Copyright © 2017 RunasSudo (Yingtong Li)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+#}
+
+{% block title %}Login{% endblock %}
+
+{% block basecontent %}
+
+
+
+
+
You have cancelled the request to log in to your account.
+
If you do wish to log in to your account, please close this window and try again.
+
+
+
+{% endblock %}
diff --git a/eosweb/redditauth/main.py b/eosweb/redditauth/main.py
index d62d53f..a2ec860 100644
--- a/eosweb/redditauth/main.py
+++ b/eosweb/redditauth/main.py
@@ -18,15 +18,11 @@ from flask_oauthlib.client import OAuth
import flask
-from eos.core.objects import *
+from eos.redditauth.election import *
import base64
import uuid
-class RedditUser(DocumentObject):
- oauth_token = StringField(is_protected=True)
- username = StringField()
-
def main(app):
oauth = OAuth()
reddit = oauth.remote_app('Reddit',