fix(auth): /auth/login sets cq_session cookie - #251
Merged
Conversation
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>
2 tasks
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>
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.
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