Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Logger getTime
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-nom committed Jun 25, 2024
1 parent 6ff4865 commit 824264e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/hooks/useLoginStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,22 @@ export const useLoginStatus = () => {

const _isTokenExpiring = _innloggetStatus.authenticated && secondsToTokenExpires < 60 * 5;
const _isSessionExpiring = secondsToSessionExpires < 60 * 10;

const now = new Date();
const nowTs = now.getTime();

if ((_isTokenExpiring || _isSessionExpiring) && now.getTime() > lastExpireLog + logPeriodMs) {
if ((_isTokenExpiring || _isSessionExpiring) && nowTs > lastExpireLog + logPeriodMs) {
logAmplitudeEvent('session-timeout', {
now: now.toISOString(),
nowTs,
session: _innloggetStatus.session,
token: _innloggetStatus.token,
secondsToSessionExpires,
secondsToTokenExpires,
securityLevel: _innloggetStatus.securityLevel,
});

lastExpireLog = now.getTime();
lastExpireLog = nowTs;
}

setIsTokenExpiring(_isTokenExpiring);
Expand Down

0 comments on commit 824264e

Please sign in to comment.