Skip to content

fix: Login recovery for /play signup when session expires (gh#1367)#150

Merged
statico-alt merged 1 commit into
mainfrom
fix/gh-1367-signup-session-recovery
Jun 27, 2026
Merged

fix: Login recovery for /play signup when session expires (gh#1367)#150
statico-alt merged 1 commit into
mainfrom
fix/gh-1367-signup-session-recovery

Conversation

@statico-alt

Copy link
Copy Markdown
Member

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

  • Added isSessionAuthError(status, message) to src/lib/apiError.ts — treats 401/403 and session-expiry/unauthorized messages as recoverable auth failures (with unit tests).
  • In PlayerSelector, when registration fails with such an error, set authExpired and render a "Log In Again" button beneath the error.
  • The button calls 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 if signOut throws. This guarantees recovery regardless of Clerk modal/active-session semantics.
  • Styling matches the existing SpaceMolt aesthetic (.reauthBtn, lucide LogIn icon, no emoji).

Testing

  • tsc --noEmit clean.
  • bun test src/lib/apiError.test.ts — 10 pass (new isSessionAuthError cases incl. the reporter's exact "Session not found or expired" message, plus negative cases for ordinary validation errors).

Player-Facing Release Notes

  • Fixed: human players whose login session expires while creating a new character on the web client now get a "Log In Again" button to re-authenticate, instead of being stuck on a "session expired" error with no way to recover.

…#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.
@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
www Ready Ready Preview, Comment Jun 27, 2026 5:19pm

Request Review

@statico-alt statico-alt merged commit bc216f2 into main Jun 27, 2026
3 checks passed
@statico-alt statico-alt deleted the fix/gh-1367-signup-session-recovery branch June 27, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant