Repository navigation
fix(agents): avatar admin gate must load role from DB — req.user has no role on JWT sessions - #1065
Merged
Merged
Conversation
middleware/auth.ts populates req.user = { id } for JWT logins — role rides
only on the cm_ API-token branch. So the avatar gate's req.user?.role check
never fired for a human in a browser; the affordance appeared only via the
installer path. Found live on fc-verify (admin, no installation, no button)
minutes after deploy. The gate now loads the caller's role from DB (one
indexed read), keeping the req.user.role fast path for API tokens.
The original admin test injected role onto req.user — the API-token shape —
which is exactly how the bug hid. New case: req.user = { id } only, role
resolved from DB, installation lookup untouched.
lilyshen0722
added a commit
that referenced
this pull request
Aug 21, 2026
ADR-022 Phase 0 (persona plan, docs/plans/2026-08-20-persona-v2-phased-
rollout.md). Measured on production: 31 of 45 active registry rows are smoke
seats (fc-verify, target, alice, bob, one row with an EMPTY name), fleet
internals (fable-lead, ux-lead, sprint-review), and personal wrappers
(xu-claude-code-local, laptop-codex). The verified flag is already the
curation boundary in the data — all 14 verified rows are the deliberate
catalog — so the route now forces verified-only for non-admins REGARDLESS of
query params; ?verified=false cannot reopen the leak. Admins keep the full
view for registry ops. Role loads from the DB, not req.user — JWT sessions
carry { id } only (the #1065 lesson, second application today).
lilyshen0722
added a commit
that referenced
this pull request
Aug 21, 2026
…ADR-022 Phase 0) (#1072) * fix(registry): seal the catalog leak — non-admins get verified rows only ADR-022 Phase 0 (persona plan, docs/plans/2026-08-20-persona-v2-phased- rollout.md). Measured on production: 31 of 45 active registry rows are smoke seats (fc-verify, target, alice, bob, one row with an EMPTY name), fleet internals (fable-lead, ux-lead, sprint-review), and personal wrappers (xu-claude-code-local, laptop-codex). The verified flag is already the curation boundary in the data — all 14 verified rows are the deliberate catalog — so the route now forces verified-only for non-admins REGARDLESS of query params; ?verified=false cannot reopen the leak. Admins keep the full view for registry ops. Role loads from the DB, not req.user — JWT sessions carry { id } only (the #1065 lesson, second application today). * test(registry): pin the verified gate from both sides Default verified-only; verified=false from a non-admin stays sealed; admin passthrough works; explicit verified=true skips the role read; parked moltbot rows stay excluded even when verified. * fix(registry): rate-limit the catalog router (CodeQL js/missing-rate-limiting) Same limiter shape as agentProfile: 120 req/min/IP keyed through cf-connecting-ip, skipped in tests. The gate added a per-request role lookup, which is what surfaced the route's pre-existing unlimited state. * test(service): the listable fixture declares verified, as real listings do The gate hid the unverified fixture from the member — working as designed against a fixture that predates the rule. The test's actual subject (ephemeral exclusion) is untouched: that row stays unverified AND ephemeral.
This was referenced Aug 25, 2026
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.
Follow-up to #1061, found during live verification: the admin branch of the avatar-edit gate tested req.user.role, but middleware/auth.ts sets req.user = { id } for JWT (browser) sessions — role exists only on the cm_ API-token path. Net effect: admins without an installation saw no edit affordance (reproduced on fc-verify). Fix loads the caller's role with one indexed read; test suite now pins both req shapes. Installer path was and remains correct (E2E-proven live on codex-impl: PUT → public profile → inline-SVG render, then restored).
🤖 Generated with Claude Code
https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8