Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 Login error for voters (#468) (#469) #470

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading