Skip to content

Commit

Permalink
✨ Increase the timeout due to user activity (#451)
Browse files Browse the repository at this point in the history
Parent issue: sequentech/meta#205
  • Loading branch information
Findeton committed Jun 25, 2024
1 parent 7964282 commit 46b6df5
Showing 1 changed file with 23 additions and 1 deletion.
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

0 comments on commit 46b6df5

Please sign in to comment.