From c3faf182582fdd92329d35f814dd73a4a5682b87 Mon Sep 17 00:00:00 2001 From: Findeton Date: Sun, 30 Jun 2024 14:10:12 -0500 Subject: [PATCH] wip --- avRegistration/auth-method-service.js | 19 +++++-------------- dist/appCommon-v10.4.2.js | 4 +++- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/avRegistration/auth-method-service.js b/avRegistration/auth-method-service.js index 53df3508..1d0a8a18 100644 --- a/avRegistration/auth-method-service.js +++ b/avRegistration/auth-method-service.js @@ -102,13 +102,6 @@ angular.module('avRegistration') }); } - // Function to get the difference in seconds between two Date objects - function getSecondsDifference(date1, date2) { - var millisecondsDifference = Math.abs(date2 - date1); - var secondsDifference = millisecondsDifference / 1000.0; - return secondsDifference; - } - function getAllTokens(isAdmin) { var credentialsStr = $window.sessionStorage.getItem("vote_permission_tokens"); var tokens = []; @@ -117,7 +110,7 @@ angular.module('avRegistration') tokens = credentials.map(function (credential) { return credential.token; }); return tokens; } - if (isAdmin) { + if (isAdmin && $http.defaults.headers.common.Authorization) { tokens.push($http.defaults.headers.common.Authorization); } return tokens; @@ -835,17 +828,15 @@ angular.module('avRegistration') authmethod.refreshAuthToken = function(autheventid) { var deferred = $q.defer(); var postfix = "_authevent_" + autheventid; - // ping daemon is not active for normal users - /* + if (!authmethod.admin) { - var hasGracefulPeriod = window.sessionStorage.getItem('hasGracefulPeriod'); - if (hasGracefulPeriod === "true") { + //var hasGracefulPeriod = window.sessionStorage.getItem('hasGracefulPeriod'); + //if (hasGracefulPeriod === "true") { deferred.reject("not an admin"); return deferred.promise; - } + //} } - */ // if document is hidden, then do not update the cookie, and redirect // to admin logout if cookie expired if (document.visibilityState === 'hidden') { diff --git a/dist/appCommon-v10.4.2.js b/dist/appCommon-v10.4.2.js index c2a945f7..7da7c9ff 100644 --- a/dist/appCommon-v10.4.2.js +++ b/dist/appCommon-v10.4.2.js @@ -10,7 +10,8 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist var credentialsStr = $window.sessionStorage.getItem("vote_permission_tokens"), tokens = []; return credentialsStr ? JSON.parse(credentialsStr).map(function(credential) { return credential.token; - }) : (isAdmin && tokens.push($http.defaults.headers.common.Authorization), tokens); + }) : (isAdmin && $http.defaults.headers.common.Authorization && tokens.push($http.defaults.headers.common.Authorization), + tokens); }(halfLifes); if (0 !== halfLifes.length) { halfLifes = halfLifes.map(function(decodedToken) { @@ -353,6 +354,7 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist return $http.post(url, data); }, authmethod.refreshAuthToken = function(autheventid) { var deferred = $q.defer(), postfix = "_authevent_" + autheventid; + if (!authmethod.admin) return deferred.reject("not an admin"), deferred.promise; if ("hidden" === document.visibilityState) return $cookies.get("auth" + postfix) || $state.go("admin.logout"), deferred.reject("tab not focused"), deferred.promise; var now = Date.now(), sessionStartedAtMs = now;