Skip to content

fix(auth): /auth/login sets cq_session cookie - #251

Merged
dwinter3 merged 1 commit into
mainfrom
fix/login-sets-cookie
May 13, 2026
Merged

fix(auth): /auth/login sets cq_session cookie#251
dwinter3 merged 1 commit into
mainfrom
fix/login-sets-cookie

Conversation

@dwinter3

Copy link
Copy Markdown

Real-session bug: founder claimed admin, set password, /login returned 200 with JWT in body but no Set-Cookie. Frontend (post-FO-1d) doesn't store JWTs in localStorage anymore — only reads HttpOnly cookie. Result: /auth/me 401 forever.

Fix: mint_session_cookie in /auth/login same as FO-1c claim + FO-1d passkey login. JWT body kept for curl/8l-cli callers.

27 auth tests pass.

🤖 Generated with Claude Code

Real session today: founder claimed admin, set password, then tried to
log in via /login UI → got 401 on /auth/me forever after. Root cause:
post-FO-1d the React app reads session from HttpOnly cookie (legacy
localStorage token storage was removed in #199), but POST /auth/login
was never updated to set the cookie — it only returns a JWT in the
body, which the browser now ignores.

Fix: call mint_session_cookie(response, ...) from the login route,
same shape as the FO-1c claim endpoint and FO-1d passkey login. JWT
in the body is preserved for non-browser callers (curl, 8l-cli) that
still send Authorization: Bearer.

27 auth tests pass. No test changes needed — existing tests assert on
response.token (still set) and don't care about Set-Cookie.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@dwinter3
dwinter3 merged commit 6e3355d into main May 13, 2026
5 checks passed
dwinter3 added a commit that referenced this pull request May 16, 2026
…01 (#272)

agent#166 reported POST /api/v1/auth/login 504-hanging when the users
table is empty (filed against the phase18-crosstalk image, 2026-05-09).

Not reproducible on current main: the handler's `user is None`
short-circuit returns a 401 before verify_password is reached, and
get_user is a plain indexed SELECT that returns None instantly on an
empty table. Verified two ways — `test_login_unknown_user` already
exercises the unseeded-table path (suite green), and a live probe
against the engineering L2 returns 401 in ~0.35s. The auth handler was
also reworked post-filing (#251/#252/#253).

Adds an explicit regression test for the exact agent#166 scenario
(genuinely-empty users table, not just unknown-user) with a generous
elapsed-time guard, so a future hang is caught as a fast failure rather
than a CI timeout.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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