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

✨ Increase the timeout due to user activity (#451) #462

Merged
merged 1 commit into from
Aug 8, 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: 23 additions & 1 deletion avBooth/booth-directive/booth-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,22 @@ angular.module('avBooth')

var idToCheck = (!!scope.parentId) ? scope.parentId : electionId;
var cookie = $cookies.get("authevent_" + idToCheck);
var authCookie = $cookies.get("auth_authevent_" + idToCheck);
if (!cookie) {
if (InsideIframeService()) {
return;
} else {
redirectToLogin(/*isSuccess*/ false);
}
}
if (!!authCookie) {
Authmethod
.setAuth(
authCookie,
false,
idToCheck
);
}
}

// override state if in debug mode and it's provided via query param
Expand Down Expand Up @@ -837,7 +846,16 @@ angular.module('avBooth')
var logoutTimeMs = getSessionStartTime() + ConfigService.authTokenExpirationSeconds * 1000;

setTimeout(
function () {
function tryTimeout() {
var newLogoutTimeMs = getSessionStartTime() + ConfigService.authTokenExpirationSeconds * 1000;
if (newLogoutTimeMs > Date.now()) {
logoutTimeMs = newLogoutTimeMs;
setTimeout(
tryTimeout,
Math.max(logoutTimeMs - Date.now(), 0)
);
return;
}
if (scope.state === stateEnum.errorScreen) {
console.log("already in an error state, can't redirect");
return;
Expand Down Expand Up @@ -1022,6 +1040,10 @@ angular.module('avBooth')
function onSuccess(response) {
scope.election = angular.fromJson(response.data.payload.configuration);
var presentation = scope.election.presentation;
let hasGracefulPeriod = presentation &&
presentation.extra_options &&
presentation.extra_options.allow_voting_end_graceful_period;
window.sessionStorage.setItem("hasGracefulPeriod", hasGracefulPeriod? "true": "false");

if (presentation.theme && presentation.theme !== ConfigService.theme) {
$("#theme").attr("href", "booth/themes/" + presentation.theme + "/app.min.css");
Expand Down
Loading