fix(frontend): restore local sessions after refresh - #2290
Open
angelo-lacson wants to merge 1 commit into
Open
Conversation
Persist local JWT sessions for up to 24 hours and restore authenticated navigation and document/corpus controls while backend user details load. Clear persisted state only for genuine authentication failures, expiry, or logout; preserve valid sessions on 403 permission denials.
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA document and I hereby sign the CLA |
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.
Summary
Fixes #2289.
Local username/password sessions now survive a full browser refresh for up to
24 hours, and authenticated navigation plus document/corpus controls remain
available while canonical backend-user details load.
This also corrects authentication error classification:
401,UNAUTHENTICATED, expired JWTs, and explicit logout clear persisted state;ordinary
403 Forbiddenpermission responses preserve the valid session.Root cause
Local authentication state lived only in Apollo reactive variables. Refreshing
the page reset the JWT and user identity before child components mounted and
issued GraphQL queries. Several UI gates also treated
userObjas the soleproof of authentication, even after
backendUserObjhad been populated.Separately, the Apollo error link treated every
403as an invalid token,conflating authorization failure with authentication failure.
Changes
handling for unavailable, malformed, or expired browser storage.
AuthGatebefore authenticatedchildren mount.
failure.
document/corpus actions.
403responses.401/403behavior.Auth0 behavior is unchanged. The client TTL does not extend the JWT's own
server-enforced lifetime.
Verification
docker compose -f local.yml --profile fullstack build frontendyarn test:unit --run src/utils/localAuthSession.test.ts src/graphql/errorLink.test.tspython3 scripts/collate_changelog.py --checkgit diff --checkManual local-Docker verification:
403does not sign the user out.Related