Repository navigation
fix(frontend): keep the user signed in when signing out fails - #32
Merged
Merged
Conversation
A sign-out whose request failed (no answer, a server or edge error, a CSRF token refused again after reading the session) still switched the SPA to signed out and went to the login page without a word, while the session and its cookie could still be valid on the server: a reload, or the next person at the same browser, was signed in again. AuthProvider.logout now changes the state only when the session has ended: after a successful answer, or a 401 (the session had already ended). Otherwise it rejects and the user stays signed in; AppShell then stays on the page and shows an alert that signing out did not complete and the user may still be signed in. Tests: App tests for a network failure, a 500, a 502 from the edge and a CSRF token refused twice (each failed before this change), and a 401 that signs out.
knittingcode
added a commit
that referenced
this pull request
Oct 25, 2026
Only the documented negative-control count conflicted: 53 with #26's three controls.
knittingcode
added a commit
that referenced
this pull request
Oct 25, 2026
Only the documented negative-control count and the test table conflicted: 64 with #26's three controls; the unit-test row keeps this branch's membership entries.
knittingcode
added a commit
that referenced
this pull request
Oct 25, 2026
…and #32) into the members page branch
This was referenced Oct 25, 2026
knittingcode
added a commit
that referenced
this pull request
Oct 25, 2026
… session it may still have Two browser cases for the #32 behaviour on the members page: a logout that never reaches the server shows the alert, keeps the page and the session (GET /me 200), and a second sign-out ends it; a logout processed by the server whose answer is lost shows the same alert, and the next change leads to the login with "Your session has ended" and changes nothing.
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
When signing out fails, the SPA now keeps the user signed in, stays on the current page and shows an alert (
role="alert"): "Signing out did not complete. You may still be signed in, so try again." Before, every failed sign-out still switched to signed out and went to the login page without a message.Motivation
ADR-019: logout ends the session on the server. If the logout request does not succeed, the session and its HttpOnly cookie can still be valid. On main,
AuthProvider.logoutreset the state to anonymous in afinally, andAppShell.signOutnavigated to/loginin afinally. The user was told nothing; a reload, or the next person at the same browser, was signed in again throughGET /api/v1/auth/session.Cases that reach this on main:
POST /api/v1/auth/logout→ 500internal-errorwith the database stopped.The UI must not claim an outcome it does not have. Found in the read-only frontend audit (AUTO3-028, FE-1).
Implementation
frontend/src/auth/AuthProvider.tsx:logoutchanges the state to anonymous only after a successful answer, or after a 401.AuthenticationTest::testLogoutEndsTheSessionOnTheServer;openapi.yaml: "204 also without a session"), so a 401 is not expected from it. The client handles it anyway, as the end of the session.frontend/src/pages/AppShell.tsx:signOutnavigates to/loginonly whenlogoutresolved. Otherwise it re-enables the button and shows the alert. The previously unhandled rejection ofvoid signOut()is gone.frontend/src/index.css:.shell-alertspacing; the alert reuses the existingform-errorstyle.Testing performed
The dev web image ran with this worktree's sources (read-only mounts), via
scratchpad/check-fe.shwith the worktree path.src/App.test.tsxgave16 tests | 4 failed. The failures werewhen the connection fails,when the API answers 500,when the edge answers 502andwhen the CSRF token is refused again after reading the session, plusVitest caught 5 unhandled errors(the rejectedsignOut).npx tsc --build:TSC-OKnpx eslint --max-warnings=0 .:ESLINT-OKnpx vitest run:Test Files 4 passed (4),Tests 41 passed (41), no unhandled errorsnpx vite build: builtgit merge-treeagainstorigin/feat/fcrm-fnd-010c-membership-uif5f31b8: clean, no conflicts). The merged frontend givesTSC-OK,ESLINT-OK,Test Files 6 passed (6),Tests 93 passed (93).e2e/auth.spec.ts("logout ends the session").Security considerations
csrf-invalidand same-origin credentials are unchanged.Known limitations
AppShell.tsx,AuthProvider.tsxorApp.test.tsx. It appends toindex.cssat the end, while this change inserts after.shell-main, so the textual merge is clean (verified withgit merge-tree).