feat: implement cross-tab coordination for token refresh and enhance logout handling
All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 3m57s

This commit is contained in:
2026-03-27 23:02:29 -04:00
parent 89097a390e
commit a4e23aad11
6 changed files with 54 additions and 11 deletions

View File

@@ -22,6 +22,7 @@ if (hasLocalStorage) {
parentAuthExpiresAt.value = parsed.expiresAt
isParentPersistent.value = true
isParentAuthenticated.value = true
startParentExpiryWatcher()
} else {
localStorage.removeItem(PARENT_AUTH_KEY)
}
@@ -81,6 +82,9 @@ export function authenticateParent(persistent: boolean) {
}
export function logoutParent() {
if (hasLocalStorage && typeof localStorage.removeItem === 'function') {
localStorage.removeItem(PARENT_AUTH_KEY)
}
applyParentLoggedOutState()
broadcastParentLogoutEvent()
}
@@ -89,9 +93,6 @@ function applyParentLoggedOutState() {
parentAuthExpiresAt.value = null
isParentPersistent.value = false
isParentAuthenticated.value = false
if (hasLocalStorage && typeof localStorage.removeItem === 'function') {
localStorage.removeItem(PARENT_AUTH_KEY)
}
stopParentExpiryWatcher()
}
@@ -105,7 +106,11 @@ function broadcastParentLogoutEvent() {
export function loginUser() {
isUserLoggedIn.value = true
// Always start in child mode after login
// Always start in child mode after login. Also explicitly remove persistent parent
// auth from localStorage so a fresh login always starts in child mode.
if (hasLocalStorage && typeof localStorage.removeItem === 'function') {
localStorage.removeItem(PARENT_AUTH_KEY)
}
applyParentLoggedOutState()
}