From d169dbd83b6437af8c6e026548f55b00c997ff9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Robles?= Date: Fri, 19 Jul 2024 14:27:16 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Separation=20of=20voting=20session?= =?UTF-8?q?=20time=20and=20bearer=20token=20lifetime=20(#404)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parent issue: https://github.com/sequentech/meta/issues/762 --- .../common-header-directive.js | 13 +++++++------ dist/appCommon-v10.4.2.js | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/avUi/common-header-directive/common-header-directive.js b/avUi/common-header-directive/common-header-directive.js index b99f9c67..9fe2a0f4 100644 --- a/avUi/common-header-directive/common-header-directive.js +++ b/avUi/common-header-directive/common-header-directive.js @@ -50,7 +50,7 @@ angular scope.showVersionsModal = ShowVersionsModalService; - function calculateCountdownPercent() { + function calculateCountdownPercent() { var ratio = (scope.logoutTimeMs - Date.now())/(scope.logoutTimeMs - scope.countdownStartTimeMs); return Math.min(100, Math.round(10000*ratio)/100) + '%'; } @@ -71,6 +71,10 @@ angular scope.logoutTimeMs = scope.$parent.getSessionEndTime(); } + if (scope.$parent.getSessionStartTime) { + scope.countdownStartTimeMs = scope.$parent.getSessionStartTime(false); + } + scope.showCountdown = true; var now = Date.now(); scope.countdownSecs = Math.round((scope.logoutTimeMs - now) / 1000); @@ -81,12 +85,9 @@ angular if (scope.countdownSecs <= 1) { return; } - var targetMins = Math.floor((scope.logoutTimeMs - now) / (60 * 1000)); - var targetNextTime = scope.logoutTimeMs - targetMins * 60 * 1000; - var targetElapsedTime = targetNextTime - now; setTimeout( updateTimedown, - targetMins > 0? targetElapsedTime : 1000 + 1000 ); } @@ -116,7 +117,7 @@ angular scope.countdownSecs = 0; scope.countdownMins = 0; - var initialTimeMs = scope.$parent.getSessionStartTime && scope.$parent.getSessionStartTime() || Date.now(); + var initialTimeMs = scope.$parent.getSessionStartTime && scope.$parent.getSessionStartTime(true) || Date.now(); scope.elapsedCountdownMs = ( election.presentation.booth_log_out__countdown_seconds > 0? election.presentation.booth_log_out__countdown_seconds : diff --git a/dist/appCommon-v10.4.2.js b/dist/appCommon-v10.4.2.js index f2f2f0e1..a1a7ead4 100644 --- a/dist/appCommon-v10.4.2.js +++ b/dist/appCommon-v10.4.2.js @@ -1205,12 +1205,12 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist } function updateTimedown() { scope.$parent.getSessionEndTime && (scope.logoutTimeMs = scope.$parent.getSessionEndTime()), + scope.$parent.getSessionStartTime && (scope.countdownStartTimeMs = scope.$parent.getSessionStartTime(!1)), scope.showCountdown = !0; - var targetMins, targetNextTime, now = Date.now(); + var now = Date.now(); scope.countdownSecs = Math.round((scope.logoutTimeMs - now) / 1e3), scope.countdownMins = Math.round((scope.logoutTimeMs - now) / 6e4), scope.countdownPercent = calculateCountdownPercent(), updateProgressBar(scope.countdownPercent), - scope.$apply(), scope.countdownSecs <= 1 || (targetMins = Math.floor((scope.logoutTimeMs - now) / 6e4), - targetNextTime = scope.logoutTimeMs - 60 * targetMins * 1e3, setTimeout(updateTimedown, 0 < targetMins ? targetNextTime - now : 1e3)); + scope.$apply(), scope.countdownSecs <= 1 || setTimeout(updateTimedown, 1e3); } scope.parentElection = scope.$parent.parentElection, scope.election = scope.$parent.election, scope.confirmLogoutModal = scope.$parent.confirmLogoutModal, scope.configService = ConfigService, @@ -1223,7 +1223,7 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist var election, initialTimeMs; scope.showCountdown = !1, scope.$parent.isStateCompatibleWithCountdown && !scope.$parent.isStateCompatibleWithCountdown() || (election = scope.parentElection || scope.election, ConfigService.authTokenExpirationSeconds && election && election.presentation && _.isNumber(election.presentation.booth_log_out__countdown_seconds) && (scope.showCountdown = !1, - scope.countdownSecs = 0, scope.countdownMins = 0, initialTimeMs = scope.$parent.getSessionStartTime && scope.$parent.getSessionStartTime() || Date.now(), + scope.countdownSecs = 0, scope.countdownMins = 0, initialTimeMs = scope.$parent.getSessionStartTime && scope.$parent.getSessionStartTime(!0) || Date.now(), scope.elapsedCountdownMs = 1e3 * (0 < election.presentation.booth_log_out__countdown_seconds ? election.presentation.booth_log_out__countdown_seconds : ConfigService.authTokenExpirationSeconds), scope.$parent.getSessionEndTime ? scope.logoutTimeMs = scope.$parent.getSessionEndTime() : scope.logoutTimeMs = initialTimeMs + 1e3 * ConfigService.authTokenExpirationSeconds, scope.countdownStartTimeMs = scope.logoutTimeMs - scope.elapsedCountdownMs, scope.countdownPercent = calculateCountdownPercent(),