Repository navigation
Sign this browser out even when the auth server fails - #39
Merged
Merged
Conversation
supabase-js 2.119 (in Dependabot's #34) changes a global signOut(): when the auth server can't be reached or returns an error, it now keeps the local session and returns the error. Our signOut action ignored that error and redirected to /login, so an admin would land there still signed in. The action now checks the error, and also catches a throw. On failure it logs the message and falls back to signOut({ scope: "local" }), which clears this browser's session cookies without needing the server, then redirects. The redirect stays outside every try/catch. The happy path is unchanged: one global sign-out, then /login. tests/sign-out.test.ts stubs the session client and covers the server accepting, being unreachable (AuthRetryableFetchError), returning a 500 (AuthApiError), throwing, and the local fallback failing too. Three of the five fail against the old action. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Githinj
added a commit
that referenced
this pull request
Nov 16, 2026
Githinj
added a commit
that referenced
this pull request
Nov 17, 2026
…41) e2e-admin/sign-out.spec.ts signs out from both places main offers it: the back-office header (an admin after MFA) and the no-access page (an account without the admin role). After each, the browser is on /login, no sb-*-auth-token cookie is left, and /admin sends the visitor back to /login. Own accounts, so it doesn't depend on the other signed-in tests. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Part of SEC-240.
Merge this before or together with #34. The bug isn't live on
maintoday. It appears when #34 brings in supabase-js 2.119.Why
supabase-js 2.119 fixed
globalsign-out (supabase/supabase-js#2786). If the auth server can't be reached or returns an error,signOut()now keeps the local session and returns the error. Before, it cleared the session anyway.Our
signOutaction ignored the error and redirected to/login. With 2.119, a failed server call would leave the admin on/loginstill signed in. The same action backs the sign-out buttons on/adminand/no-access, and on #16's branch also/portaland/portal/mfa.Change
src/app/(app)/admin/actions.ts:signOut()checks the returned error and also catches a throw.failed()does for other actions), then callssignOut({ scope: "local" }), which supabase-js's own migration note recommends.redirect("/login")stays outside everytry/catch, because it works by throwing./login.signOut(), including its comment. Phase 1C: client portal #16 and Record which video platform serves each site (SEC-264) #25 addinviteClientUserdirectly above it. With the change kept inside, both branches test-merge with this one without conflicts (git merge-tree).Tests
tests/sign-out.test.tsstubscreateSessionClient. It also makesredirectthrow, as Next.js does. It covers five cases:/login, nothing loggedAuthRetryableFetchError)AuthApiError)/loginThree of the five fail against the old action.
Run locally: white-label check, typecheck, lint, and
vitest run(95 passed). No build or browser tests were run locally; CI runs both. No browser test presses Sign out today (e2e-admin/has no sign-out step), so the real-stack path is covered only by these unit tests.🤖 Generated with Claude Code