Skip to content

fix: navigating non-player to spectate - #1341

Merged
itsalaidbacklife merged 7 commits into
cuttle-cards:mainfrom
haaarsh619:fix/non-player-navigation
Aug 18, 2026
Merged

fix: navigating non-player to spectate#1341
itsalaidbacklife merged 7 commits into
cuttle-cards:mainfrom
haaarsh619:fix/non-player-navigation

Conversation

@haaarsh619

Copy link
Copy Markdown
Contributor

Issue number #1319

Relevant issue number

Please check the following

  • Do the tests still pass? (see Run the Tests)
  • Is the code formatted properly? (see Linting (Formatting))
  • For New Features:
    • Have tests been added to cover any new features or fixes?
    • Has the documentation been updated accordingly?

Please describe additional details for testing this change

haaarsh619 and others added 6 commits February 24, 2026 21:53
The non-player check dereferenced `response.game.players` unconditionally.
On a 401, `requestGameState` sets `mustReauthenticate` and resolves with a
message string rather than a game state, so that dereference threw a
TypeError. The guard's own catch turned it into a redirect to Home, whose
`mustBeAuthenticated` guard then bounced to /login -- losing the game the
player was in.

Only run the check when the response actually carries a game state, so a
lost session falls through to GameView and its ReauthenticateDialog. This
also covers the response shape get-game returns for a game with no
gameStates, which likewise has no `game` key.

Adds the regression test issue cuttle-cards#1319 never got, mirroring the existing
"Prevents spectating your own game while it's ongoing" case.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@itsalaidbacklife itsalaidbacklife added version-patch An update that warrants a bumping the project's patch version (e.g. 4.0.0 => 4.0.1) enhancement New feature or request labels Aug 18, 2026
Resolving `jwres.body.message` gave callers a plain string where they
expect a game state, which is what let the non-player spectate check
throw a TypeError on a lost session. No caller consumed that string, so
resolve null instead and make the "no game state" contract explicit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@itsalaidbacklife
itsalaidbacklife merged commit a800fe6 into cuttle-cards:main Aug 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request version-patch An update that warrants a bumping the project's patch version (e.g. 4.0.0 => 4.0.1)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Navigating to /game/:gameId as a non-player shows blank screen instead of redirecting to /spectate/:gameId

3 participants