fix: auto-logout not working when closing tabs and reopening

Signed-off-by: Juan Escalada <juanescalada175@gmail.com>
This commit is contained in:
Juan Escalada
2025-10-18 12:27:06 +09:00
parent 52b647ee47
commit 2259e99a6e
2 changed files with 9 additions and 8 deletions
@@ -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,