fix: Login recovery for /play signup when session expires (gh#1367)#150
Merged
Conversation
…#1367) When a human's Clerk session expires mid-signup, the player-creation form surfaced the gameserver's 'Session not found or expired' error but offered no way to re-authenticate, leaving the user stuck. Detect session/auth errors during registration and show a 'Log In Again' button that signs the stale session out and returns to /play so the user can sign back in and retry. Reported via Discord by rsned; tracked as gh#1367.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Problem
On
/play, when a human's Clerk auth session expires mid-signup, the player-creation form (PlayerSelector.tsx) showed the gameserver's "Session not found or expired" error but offered no way to re-authenticate — only Back and Create buttons. The Clerk sign-in screen only appears before a user is selected, so a human whose session lapsed during signup was stuck with no recovery path. Reported via Discord by rsned; tracked as gh#1367.Approach
isSessionAuthError(status, message)tosrc/lib/apiError.ts— treats 401/403 and session-expiry/unauthorized messages as recoverable auth failures (with unit tests).PlayerSelector, when registration fails with such an error, setauthExpiredand render a "Log In Again" button beneath the error.signOut({ redirectUrl: '/play' }), clearing the stale Clerk session and returning the user to/play, where the existing sign-in screen lets them re-authenticate and retry. Falls back to a hard reload ifsignOutthrows. This guarantees recovery regardless of Clerk modal/active-session semantics..reauthBtn, lucideLogInicon, no emoji).Testing
tsc --noEmitclean.bun test src/lib/apiError.test.ts— 10 pass (newisSessionAuthErrorcases incl. the reporter's exact "Session not found or expired" message, plus negative cases for ordinary validation errors).Player-Facing Release Notes