Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Findeton committed Jun 30, 2024
1 parent c220969 commit c3faf18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
19 changes: 5 additions & 14 deletions avRegistration/auth-method-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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;
Expand Down Expand Up @@ -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') {
Expand Down
4 changes: 3 additions & 1 deletion dist/appCommon-v10.4.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c3faf18

Please sign in to comment.