Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
edulix committed Jun 19, 2024
1 parent fcab817 commit f5fef1f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
21 changes: 0 additions & 21 deletions avRegistration/auth-method-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ angular.module('avRegistration')
// Variable to store the last interaction time
var lastInteractionTime = isPerformanceApiAvailable() ? performance.now() : 0;

// Function to update the last interaction time
function updateLastInteractionTime() {
if (typeof performance !== 'undefined' && typeof performance.now === 'function') {
lastInteractionTime = performance.now();
localStorage.setItem('lastInteractionTime', lastInteractionTime);
}
}

// Function to get the time since the last interaction in milliseconds
function getTimeSinceLastInteraction() {
return isPerformanceApiAvailable() ? (performance.now() - lastInteractionTime) : Infinity;
Expand All @@ -82,16 +74,6 @@ angular.module('avRegistration')
callback();
}
}

// Event listener for user interactions
function setupInteractionListeners() {
if (isPerformanceApiAvailable()) {
var events = ['click', 'keypress', 'mousemove', 'touchstart'];
events.forEach(function (event) {
document.addEventListener(event, updateLastInteractionTime);
});
}
}

// Function to get the difference in seconds between two Date objects
function getSecondsDifference(date1, date2) {
Expand All @@ -106,9 +88,6 @@ angular.module('avRegistration')
authmethod.lastAuthDate = new Date();

if (!authmethod.pingTimeout) {
// Initialize the interaction listeners
setupInteractionListeners();

$interval.cancel(authmethod.pingTimeout);
authmethod.refreshAuthToken(autheventid);

Expand Down
10 changes: 2 additions & 8 deletions dist/appCommon-v10.4.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,13 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
authevent;
};
var lastInteractionTime = isPerformanceApiAvailable() ? performance.now() : 0;
function updateLastInteractionTime() {
"undefined" != typeof performance && "function" == typeof performance.now && (lastInteractionTime = performance.now(),
localStorage.setItem("lastInteractionTime", lastInteractionTime));
}
function wasInteractionWithinLastXSeconds(seconds, callback) {
(isPerformanceApiAvailable() ? performance.now() - lastInteractionTime : 1 / 0) <= 1e3 * seconds && callback();
}
return authmethod.setAuth = function(auth, isAdmin, autheventid) {
return authmethod.admin = isAdmin, $http.defaults.headers.common.Authorization = auth,
authmethod.lastAuthDate = new Date(), authmethod.pingTimeout || (isPerformanceApiAvailable() && [ "click", "keypress", "mousemove", "touchstart" ].forEach(function(event) {
document.addEventListener(event, updateLastInteractionTime);
}), $interval.cancel(authmethod.pingTimeout), authmethod.refreshAuthToken(autheventid),
authmethod.pingTimeout = $interval(function() {
authmethod.lastAuthDate = new Date(), authmethod.pingTimeout || ($interval.cancel(authmethod.pingTimeout),
authmethod.refreshAuthToken(autheventid), authmethod.pingTimeout = $interval(function() {
console.log("authmethod.pingTimeout.."), wasInteractionWithinLastXSeconds(5, function() {
var date1, date2;
console.log("wasInteractionWithinLastXSeconds.."), (date1 = authmethod.lastAuthDate,
Expand Down

0 comments on commit f5fef1f

Please sign in to comment.