Skip to content

Commit

Permalink
✨ Voter eligibility check (#408)
Browse files Browse the repository at this point in the history
Parent issue: sequentech/meta#234
  • Loading branch information
Findeton authored Aug 8, 2024
1 parent a8a38a0 commit 89b88be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
6 changes: 4 additions & 2 deletions avRegistration/login-directive/login-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ angular.module('avRegistration')
function link(scope, element, attrs)
{
scope.isCensusQuery = attrs.isCensusQuery;
scope.isQuery = "true" === $location.search()['query'];
scope.withCode = attrs.withCode;
scope.username = attrs.username;
scope.isOtl = attrs.isOtl;
Expand Down Expand Up @@ -690,6 +691,7 @@ angular.module('avRegistration')
$cookies.put("auth" + postfix, authToken, options);
$cookies.put("isAdmin" + postfix, scope.isAdmin, options);
Authmethod.setAuth(authToken, scope.isAdmin, autheventid);
var votingScreenPath = (scope.isQuery || (scope.base_authevent && scope.base_authevent.force_census_query)) ? '/eligibility' : '/vote';
if (scope.isAdmin)
{
Authmethod.getUserInfo()
Expand Down Expand Up @@ -732,7 +734,7 @@ angular.module('avRegistration')
"show-pdf",
!!response.data['show-pdf']
);
$window.location.href = '/booth/' + autheventid + '/vote';
$window.location.href = '/booth/' + autheventid + votingScreenPath;
}
// if it's an election with children elections then show access to them
else if (angular.isDefined(response.data['vote-children-info']))
Expand Down Expand Up @@ -761,7 +763,7 @@ angular.module('avRegistration')
JSON.stringify(tokens)
);

$window.location.href = '/booth/' + autheventid + '/vote';
$window.location.href = '/booth/' + autheventid + votingScreenPath;
} else {
setError(
"unrecognizedServerResponse",
Expand Down
1 change: 1 addition & 0 deletions avUi/election-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ angular.module('avUi')
num_successful_logins_allowed: el.num_successful_logins_allowed,
scheduled_events: el.scheduled_events || null,
allow_public_census_query: el.allow_public_census_query,
force_census_query: el.force_census_query || false,
hide_default_login_lookup_field: el.hide_default_login_lookup_field,
parent_id: el.parent_id || null,
children_election_info: el.children_election_info || null,
Expand Down
23 changes: 13 additions & 10 deletions dist/appCommon-vmaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,11 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
restrict: "AE",
scope: !0,
link: function(scope, element, attrs) {
scope.isCensusQuery = attrs.isCensusQuery, scope.withCode = attrs.withCode, scope.username = attrs.username,
scope.isOtl = attrs.isOtl, scope.isOpenId = attrs.isOpenId, scope.otlSecret = attrs.otlSecret,
scope.error = null, scope.errorData = null, scope.current_alt_auth_method_id = void 0,
scope.alternative_auth_methods = null, scope.csrf = null, attrs.withAltMethod && attrs.selectedAltMethod ? scope.selectedAltMethod = attrs.selectedAltMethod : scope.selectedAltMethod = null,
scope.isCensusQuery = attrs.isCensusQuery, scope.isQuery = "true" === $location.search().query,
scope.withCode = attrs.withCode, scope.username = attrs.username, scope.isOtl = attrs.isOtl,
scope.isOpenId = attrs.isOpenId, scope.otlSecret = attrs.otlSecret, scope.error = null,
scope.errorData = null, scope.current_alt_auth_method_id = void 0, scope.alternative_auth_methods = null,
scope.csrf = null, attrs.withAltMethod && attrs.selectedAltMethod ? scope.selectedAltMethod = attrs.selectedAltMethod : scope.selectedAltMethod = null,
scope.hide_default_login_lookup_field = !1;
var adminId = ConfigService.freeAuthId + "", autheventid = null;
function simpleRedirectToLogin() {
Expand Down Expand Up @@ -616,14 +617,15 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
scope.sendingData = !0, setError(null, null);
var sessionStartedAtMs = Date.now();
Authmethod.login(data, autheventid).then(function(tokens) {
var postfix, options, decodedToken, decodedAccessToken;
var postfix, options, votingScreenPath, decodedAccessToken;
"ok" === tokens.data.status ? (postfix = "_authevent_" + autheventid, options = {},
decodedAccessToken = tokens.data["auth-token"], decodedToken = Authmethod.decodeToken(decodedAccessToken),
options.expires = new Date(sessionStartedAtMs + 1e3 * decodedToken.expiry_secs_diff),
decodedAccessToken = tokens.data["auth-token"], votingScreenPath = Authmethod.decodeToken(decodedAccessToken),
options.expires = new Date(sessionStartedAtMs + 1e3 * votingScreenPath.expiry_secs_diff),
$cookies.put("authevent_" + autheventid, autheventid, options), $cookies.put("userid" + postfix, tokens.data.username, options),
$cookies.put("user" + postfix, scope.email || tokens.data.username || tokens.data.email, options),
$cookies.put("auth" + postfix, decodedAccessToken, options), $cookies.put("isAdmin" + postfix, scope.isAdmin, options),
Authmethod.setAuth(decodedAccessToken, scope.isAdmin, autheventid), scope.isAdmin ? Authmethod.getUserInfo().then(function(response) {
Authmethod.setAuth(decodedAccessToken, scope.isAdmin, autheventid), votingScreenPath = scope.isQuery || scope.base_authevent && scope.base_authevent.force_census_query ? "/eligibility" : "/vote",
scope.isAdmin ? Authmethod.getUserInfo().then(function(response) {
var redirectUrl = $window.sessionStorage.getItem("redirect");
redirectUrl ? $window.sessionStorage.removeItem("redirect") : redirectUrl = "/admin/elections",
$cookies.put("user" + postfix, response.data.email || scope.email || response.data.username, options),
Expand All @@ -637,7 +639,7 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
isFirst: !0,
sessionStartedAtMs: sessionStartedAtMs,
sessionEndsAtMs: sessionStartedAtMs + 1e3 * decodedAccessToken.expiry_secs_diff
} ])), $window.sessionStorage.setItem("show-pdf", !!tokens.data["show-pdf"]), $window.location.href = "/booth/" + autheventid + "/vote") : angular.isDefined(tokens.data["vote-children-info"]) ? (tokens = _.chain(tokens.data["vote-children-info"]).map(function(child, index) {
} ])), $window.sessionStorage.setItem("show-pdf", !!tokens.data["show-pdf"]), $window.location.href = "/booth/" + autheventid + votingScreenPath) : angular.isDefined(tokens.data["vote-children-info"]) ? (tokens = _.chain(tokens.data["vote-children-info"]).map(function(child, index) {
var decodedAccessToken = child["vote-permission-token"], decodedAccessToken = decodedAccessToken && Authmethod.decodeToken(decodedAccessToken) || null;
return {
electionId: child["auth-event-id"],
Expand All @@ -651,7 +653,7 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
sessionEndsAtMs: sessionStartedAtMs + 1e3 * (decodedAccessToken && decodedAccessToken.expiry_secs_diff || null)
};
}).value(), $window.sessionStorage.setItem("vote_permission_tokens", JSON.stringify(tokens)),
$window.location.href = "/booth/" + autheventid + "/vote") : setError("unrecognizedServerResponse", "avRegistration.loginError." + scope.method + ".unrecognizedServerResponse")) : (scope.sendingData = !1,
$window.location.href = "/booth/" + autheventid + votingScreenPath) : setError("unrecognizedServerResponse", "avRegistration.loginError." + scope.method + ".unrecognizedServerResponse")) : (scope.sendingData = !1,
setError("invalidServerResponse", "avRegistration.loginError." + scope.method + ".invalidServerResponse"));
}, function(codename) {
scope.sendingData = !1;
Expand Down Expand Up @@ -1569,6 +1571,7 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
num_successful_logins_allowed: el.num_successful_logins_allowed,
scheduled_events: el.scheduled_events || null,
allow_public_census_query: el.allow_public_census_query,
force_census_query: el.force_census_query || !1,
hide_default_login_lookup_field: el.hide_default_login_lookup_field,
parent_id: el.parent_id || null,
children_election_info: el.children_election_info || null,
Expand Down

0 comments on commit 89b88be

Please sign in to comment.