Skip to content

Commit

Permalink
🐞 Login error for voters (#468) (#469) (#470)
Browse files Browse the repository at this point in the history
Parent issue: sequentech/meta#1832
  • Loading branch information
Findeton committed Sep 6, 2024
1 parent 7500d64 commit 6afe302
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions avBooth/booth-directive/booth-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,14 +727,10 @@ angular.module('avBooth')
try {
scope.credentials = JSON.parse(credentialsStr);

// if it's virtual, there's no current election credentials
if (scope.isVirtual) {
return;
}
currentElectionCredentials = _.find(
scope.credentials,
function (electionCredential) {
return electionCredential.electionId.toString() === scope.electionId && !!electionCredential.token;
return (scope.isVirtual || electionCredential.electionId.toString() === scope.electionId) && !!electionCredential.token;
}
);
} catch (error) {
Expand All @@ -747,6 +743,10 @@ angular.module('avBooth')
);
return;
}
// if it's virtual, there's no current election credentials
if (scope.isVirtual) {
return currentElectionCredentials;
}

// credentials for current election should have been found
if (!currentElectionCredentials)
Expand Down Expand Up @@ -820,15 +820,21 @@ angular.module('avBooth')
}

function getSessionEndTime() {
readVoteCredentials();
return scope.sessionEndsAtMs || scope.currentElectionCredentials && scope.currentElectionCredentials.sessionEndsAtMs || (scope.startTimeMs + ConfigService.authTokenExpirationSeconds * 1000);
let currentElectionCredentials = readVoteCredentials();
return scope.sessionEndsAtMs ||
(scope.currentElectionCredentials && scope.currentElectionCredentials.sessionEndsAtMs) ||
(currentElectionCredentials && currentElectionCredentials.sessionEndsAtMs) ||
(scope.startTimeMs + ConfigService.authTokenExpirationSeconds * 1000);
}

function getSessionStartTime(readCredentials) {
let currentElectionCredentials;
if (readCredentials) {
readVoteCredentials();
currentElectionCredentials = readVoteCredentials();
}
return scope.startTimeMs || (scope.currentElectionCredentials && scope.currentElectionCredentials.sessionStartedAtMs);
return (currentElectionCredentials && currentElectionCredentials.sessionStartedAtMs) ||
(scope.currentElectionCredentials && scope.currentElectionCredentials.sessionStartedAtMs) ||
scope.startTimeMs;
}

// After cookies expires, redirect to login. But only if cookies do
Expand Down

0 comments on commit 6afe302

Please sign in to comment.