Skip to content

Commit

Permalink
fixing isFirst in vote-permission-token processing. it should indicat…
Browse files Browse the repository at this point in the history
…e if it's the first token, not the first election in the natural order list (#174)
  • Loading branch information
edulix authored Dec 23, 2021
1 parent b01f3fb commit 150918e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 9 additions & 2 deletions avRegistration/login-directive/login-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,24 @@ angular.module('avRegistration')
else if (angular.isDefined(response.data['vote-children-info']))
{
// assumes the authapi response has the same children
var tokenIndex = 0;
var tokens = _
.chain(response.data['vote-children-info'])
.map(function (child, index) {
.map(function (child) {
if (!!child['vote-permission-token']) {
tokenIndex += 1;
}
return {
electionId: child['auth-event-id'],
token: child['vote-permission-token'] || null,
skipped: false,
voted: false,
numSuccessfulLoginsAllowed: child['num-successful-logins-allowed'],
numSuccessfulLogins: child['num-successful-logins'],
isFirst: index === 0
isFirst: (
!!child['vote-permission-token'] &&
tokenIndex === 1
)
};
})
.value();
Expand Down
9 changes: 5 additions & 4 deletions dist/appCommon-v5.0.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
data[field.name] = field.value;
}), "smart-link" === scope.method && (data["auth-token"] = $location.search()["auth-token"]),
scope.sendingData = !0, scope.error = null, Authmethod.login(data, autheventid).then(function(tokens) {
var postfix, options;
var postfix, options, tokenIndex;
"ok" === tokens.data.status ? (postfix = "_authevent_" + autheventid, options = {},
ConfigService.cookies && ConfigService.cookies.expires && (options.expires = new Date(),
options.expires.setMinutes(options.expires.getMinutes() + ConfigService.cookies.expires)),
Expand All @@ -447,15 +447,16 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
}) : angular.isDefined(tokens.data["redirect-to-url"]) ? $window.location.href = tokens.data["redirect-to-url"] : angular.isDefined(tokens.data["vote-permission-token"]) ? ($window.sessionStorage.setItem("vote_permission_tokens", JSON.stringify([ {
electionId: autheventid,
token: tokens.data["vote-permission-token"]
} ])), $window.location.href = "/booth/" + autheventid + "/vote") : angular.isDefined(tokens.data["vote-children-info"]) ? (tokens = _.chain(tokens.data["vote-children-info"]).map(function(child, index) {
return {
} ])), $window.location.href = "/booth/" + autheventid + "/vote") : angular.isDefined(tokens.data["vote-children-info"]) ? (tokenIndex = 0,
tokens = _.chain(tokens.data["vote-children-info"]).map(function(child) {
return child["vote-permission-token"] && (tokenIndex += 1), {
electionId: child["auth-event-id"],
token: child["vote-permission-token"] || null,
skipped: !1,
voted: !1,
numSuccessfulLoginsAllowed: child["num-successful-logins-allowed"],
numSuccessfulLogins: child["num-successful-logins"],
isFirst: 0 === index
isFirst: !!child["vote-permission-token"] && 1 === tokenIndex
};
}).value(), $window.sessionStorage.setItem("vote_permission_tokens", JSON.stringify(tokens)),
$window.location.href = "/booth/" + autheventid + "/vote") : scope.error = $i18next("avRegistration.invalidCredentials", {
Expand Down

0 comments on commit 150918e

Please sign in to comment.