Repository navigation
fix(auth): suppress session expiration warnings for visitors - #330
Merged
Merged
Conversation
Record expiration notices in the auth provider for the session that was actually invalidated. Route unauthenticated dashboard visitors to plain login and show each confirmed expiration once.
overtrue
approved these changes
Dec 1, 2026
overtrue
left a comment
Collaborator
There was a problem hiding this comment.
LGTM.
Review Summary
lib/auth-session.ts(getSessionExpiration,isValidCredentials):- Extracting
getSessionExpirationcleanly separates structural + timestamp validity from theexpiration > nowcheck without changingisValidCredentialssemantics.
- Extracting
contexts/auth-context.tsx(AuthProvider,expireSession,consumeSessionExpirationNotice):- Using a paired
Symbol()state + ref (sessionExpiration/pendingSessionExpiration) ensures expiration notices are strictly one-shot, survive React StrictMode effect replays without duplicate toasts, and only trigger when the expired session carried a validExpirationtimestamp. - Clearing
pendingSessionExpiration.currentinlogin,logout, and theuseLayoutEffectcross-tab authentication guard—plus verifying!isValidCredentials(getStoredCredentials())on consume—prevents stale warnings after manual logout, cross-tab sign-out, or concurrent cross-tab login replacement.
- Using a paired
components/dashboard-auth-guard.tsx,contexts/api-context.tsx,contexts/s3-context.tsx,app/(auth)/auth/login/page.tsx:- Removing the
?unauthorized=truequery flag from redirects and consuming the auth-context notice on the login page cleanly separates anonymous visitors from expired sessions.
- Removing the
- Tests (
tests/hooks/use-oidc-logout.test.ts,tests/hooks/use-permissions-refresh.test.ts,tests/lib/form-interaction.test.ts):- Well-covered across first-visit redirects, API/S3 401 expirations, timer expirations, invalid vs expired stored credentials, StrictMode double-effect replay, cross-tab sign-out, and batched cross-tab session replacement. All 10 CI checks passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Opening a dashboard route with an empty browser session could display “Your session has expired” on the login page. The dashboard guard supplied the same URL flag for visitors and expired sessions.
The guard now sends unauthenticated visitors to the plain login URL. The auth provider records a one-time warning when the current session expires or is rejected by the admin API or S3. The login page consumes that warning, and a replacement session clears any pending notice from the previous session.
Type of Change
Testing
Chrome against the local production static export verified a first visit to the Console home and Buckets pages, direct login with and without the legacy URL flag, and warnings for expired stored sessions.
Checklist
Related Issues
N/A
Screenshots (if applicable)
Additional Notes
N/A