fix: auto-logout not working when closing tabs and reopening
Signed-off-by: Juan Escalada <juanescalada175@gmail.com>
This commit is contained in:
@@ -146,8 +146,14 @@ const ConditionalAutoLogout = ({
|
||||
onPrompt: promptBeforeIdle ? onPrompt : undefined,
|
||||
promptBeforeIdle: promptBeforeIdle ? promptBeforeIdleMillis : undefined,
|
||||
syncTimers: 1000,
|
||||
leaderElection: true,
|
||||
});
|
||||
|
||||
// Check if the current tab is the only active tab. In practice, this gets checked once per second
|
||||
if (timer.isLeader()) {
|
||||
lastSeenOnlineStore.save(new Date());
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{promptBeforeIdle && (
|
||||
|
||||
@@ -51,16 +51,11 @@ export const useLogoutDisconnectedUserEffect = ({
|
||||
);
|
||||
if (nowSeconds - lastSeenOnlineSeconds > idleTimeoutSeconds) {
|
||||
identityApi.signOut();
|
||||
// Delete lastSeen time to prevent getting locked out after logout
|
||||
lastSeenOnlineStore.delete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* save for the first time when app is loaded, so that
|
||||
* if user logs in and does nothing we still have a
|
||||
* lastSeenOnline value in store
|
||||
*/
|
||||
lastSeenOnlineStore.save(new Date());
|
||||
} else {
|
||||
lastSeenOnlineStore.delete();
|
||||
}
|
||||
}, [
|
||||
autologoutIsEnabled,
|
||||
|
||||
Reference in New Issue
Block a user