feat(admin-ui): a stale cookie sends you to sign in (STORY-475) - #840
Merged
Merged
Conversation
lib/api-fetch.ts: a 401 posts /api/auth/logout (the cookie is HttpOnly), hard-navigates to /login?expired=1 and never settles; other non-ok statuses reject with the Response. The four lib 401 branches are gone. The About server component redirects to /session-expired, a route that clears genwave-auth and 307s to a relative /login?expired=1. The login page reads the flag. middleware.ts is unchanged (F208.2).
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
🧭 What
PR-7 of the launch-polish epic (STORY-475, gh-#729), shipping in v5.13.0.
admin-ui/lib/api-fetch.ts. On a 401 it posts/api/auth/logoutto clear the HttpOnlygenwave-authcookie, then does a full page load to/login?expired=1. Its promise never settles, so no error toast flashes before the page leaves. Any other non-ok status rejects with theResponse.broadcast-api,use-row-patch,persona-taste-apiandstation-thumb-apinow callapiFetch. Every non-401 outcome and message is unchanged./session-expiredroute. That route clears the cookie and sends the browser to/login?expired=1, using a relative redirect so it works on any host name.?expired=1it shows "Your session ended. Sign in again."middleware.tsis unchanged; it still only checks that the cookie exists.Closes #729
✅ Verified
tsc,typecheck:specs, lint (0 errors), jest (129 suites, 1368 passed) andnext buildall pass. A spec scans the source and fails on any 401 comparison orcase 401outsidelib/api-fetch.ts./login?expired=1with "Your session ended. Sign in again."; the cookie is goneGET /aboutwith a junk cookie/session-expiredGET /session-expiredwithHost: genwave.localLocation: /login?expired=1;Set-Cookie: genwave-auth=; Path=/; Max-Age=0apidoes not end a session. The key ring is kept on thedp_keysvolume by design, so the wire test used a junk cookie instead./session-expiredis a GET that signs you out, so another site can link you into being signed out. Nothing is exposed and no server state changes. ASec-Fetch-Sitecheck could harden it later.apiFetchyet, so a 401 there still shows each page's own error. This PR moves only the five former 401 sites.