Skip to content

fix: blog, changelog and docs headers signed in only when the session check passes (CORE-1326) - #341

Open
sonpiaz wants to merge 2 commits into
mainfrom
fix/core1326-auth-state-p633
Open

sonpiaz wants to merge 2 commits into
mainfrom
fix/core1326-auth-state-p633

Conversation

@sonpiaz

@sonpiaz sonpiaz commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

What

With an expired or rejected session the browser still holds csrf_token. The blog, changelog and docs headers treated that cookie alone as "signed in" and showed Dashboard, while the home page, /about and /marketplace showed the signed-out header.

Now the header and every PublicLink share one probeMe() read per page view (the dashboard's own session read, in its optional mode). The visitor counts as signed in only when it returns a person. Nobody (200 null, 401, 403) and an unusable answer (5xx, network) both show the signed-out header. Without csrf_token no request is made.

Evidence on production (before)

A headless browser with a fake auth_token and a leftover csrf_token, public pages only:

Page Header Session read
/, /about, /marketplace signed out 200 null
/blog, /changelog, /docs Dashboard 200 null (twice)

Tests

tests/session-check.test.ts, run with node --test --experimental-strip-types tests/session-check.test.ts (no dependencies). 7 cases:

  • an expired session (200 null) is signed out;
  • 401 is signed out;
  • 500 and a network failure are signed out;
  • a verified session is signed in;
  • no csrf_token means no request;
  • 12 callers make 1 request;
  • a rejected probe is signed out.

The old cookie-only rule fails 4 of 7. Mutants also fail: no shared answer, a request without a cookie, "unavailable counts as signed in", and a rejection that propagates.

tsconfig.json excludes tests/, so the app type-check does not read the test's .ts import.

Cost

  • No request for visitors without csrf_token, as before.
  • One shared /me read for visitors with it. The account menu now renders only for a verified person, so a leftover cookie no longer triggers its two reads.

🤖 Generated with Claude Code

…sion check passes (CORE-1326)

With an expired or rejected session the browser keeps csrf_token, and these headers showed
"Dashboard" on cookie presence alone while the home page showed "Sign in". The header and every
PublicLink now share one probeMe read per page view (GET /api/users/me?optional=1, the dashboard's
own check): signed in only when it finds a person. No csrf_token means no request.

Tests: tests/session-check.test.ts (node --test --experimental-strip-types, no dependencies);
the old cookie-only rule fails 4 of 7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
affitor-docs Ready Ready Preview Dec 5, 2026 10:37pm UTC

Request Review

@sonpiaz
sonpiaz marked this pull request as ready for review December 5, 2026 22:33
A client-side navigation reads again, so a transient failure or a sign-out in another tab is not
carried from page to page. Callers on the same page still share one read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — ad32c5ae Deployed Dec 5, 2026 by vercel[bot]
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