Repository navigation
feat(auth): the login plugin, with magic-link request and redeem endpoints - #847
Conversation
…points Adds `loginPlugin`: one hidden `magicLinkIssuedAt` timestamp plus the two endpoints that trade an emailed link for an admin session. Passwords keep working — this is a second way in, not a cut-over. `session.ts` generalises past `managers`: `createSession(payload, slug, id)` mints for any auth collection the plugin's options name, and refuses one carrying no `sessions` field. `clients` is that case — `disableLocalStrategy` means Payload adds neither `sessions` nor `email`, so a token minted for it would authenticate nothing. The two token kinds are separate JWT audiences, so an aged invitation cannot be replayed as a sign-in. `magicLinkIssuedAt` carries three jobs at once: the 60-second throttle (the only in-app bound on per-account link volume, since `rateLimitHook` is a no-op and the edge cannot see the email), the claim the consume route matches exactly, and the clear that makes a link single-use. `requestLink` answers identically for a link sent, an unknown address, an inactive manager and a throttled repeat — any difference is an enumeration oracle on an anonymous endpoint. Refs #837 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015xud3n3UF2tPLDxiZmncZV
Fifteen integration assertions through the real REST pipeline, anonymously, plus a unit spec pinning the two token audiences as a closed set against the three kinds already in use. Each load-bearing assertion was watched fail at the defect's real site: the uniform `request-link` answer against a 429 on throttle, the throttle against its removal, the claim equality against its removal, and the endpoint append against a replacement that deletes `setProject`. `createTestEnvironmentWithEmail` now returns its config, so a suite needing both captured mail and `handleEndpoints` no longer has to choose. Also documents the plugin-wired-endpoint split in docs/rules/endpoints.md. Refs #837 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015xud3n3UF2tPLDxiZmncZV
Four independent review passes converged on the same defect: the endpoints advertised a collection-agnostic slug parameter their bodies contradict. They branch on `type === 'inactive'`, an enum only `managers` declares, send from `MANAGER_EMAIL_FROM` with a manager-shaped template, and verify audiences named `manager-signin` / `manager-invite`. A second collection would have got the routes, a wrong predicate and the wrong branding. They are now plain `Endpoint` constants over `'managers'`, like `setProject` beside them and like `formsPlugin`'s `user-submissions` wiring. That removes four `as never` casts and both hand-written shadow types — a `Candidate` widened `type` to `string`, so `=== 'Inactive'` type-checked in the two places the inactive check IS the gate. They are `Pick<Manager, …>` now. `createSession` keeps its slug and its `sessions` guard: it is the piece a second auth collection genuinely reuses. Also from the review: both reads gain a bounded `select`; the email's "valid for" string derives from `SIGNIN_TOKEN_TTL_MS` rather than restating it; the send routes its header text through `emailSafeText`, as six of the seven other senders do; `createAnonRestClient` joins `tests/utils/restRequest.ts` instead of the spec rebuilding `handleEndpoints` three times. Refs #837 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015xud3n3UF2tPLDxiZmncZV
From the branch security review. Self-access grants a manager update on their own document, so the field's "requestLink is its only writer" was prose rather than enforcement: a manager could re-arm or burn their own outstanding link, or stamp a future instant and throttle their own sends forever. `update: () => false` matches the lock Payload puts on the `sessions` field beside it, and both endpoints write through `overrideAccess: true`. Also records the one hazard the review found and could not rule out by design: these tokens share `payload.secret` with Payload's session JWTs, and `JWTAuthentication` pins neither algorithm nor audience. A link token is refused as a session credential by two independent accidents of that verifier — the claim is `userId` not `id`, and there is no `sid`. Now asserted rather than trusted; adding an `id` claim alone was measured not to flip it. Refs #837 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015xud3n3UF2tPLDxiZmncZV
- `src/collections/AGENTS.md` — the Login plugin beside SEO and Form Builder: the field's three jobs, why both routes are anonymous, and that the plugin appends rather than replaces. - `docs/rules/access.md` — all four localized-roles hooks fire on an auth RESPONSE, which is why the consume route redirects instead of returning a user. Any future route that mints its own session owes the same choice. - `docs/rules/endpoints.md` — the plugin-wired-endpoint split, keyed on a literal slug. - `tests/AGENTS.md` — `createAnonRestClient` / `createRestClientWithAuth`. Refs #837 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015xud3n3UF2tPLDxiZmncZV
|
🚅 Deployed to the SahajCloud-pr-847 environment in sahajcloud
1 service not affected by this PR
|
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the ticket's size and shape. Keying on the literal slug beats the collections option it replaced, the plugin appends rather than replaces, and nothing here is unasked-for.
Two gaps, both about who the routes let through. Managers.auth.verify is configured, so an unverified manager spends a link and lands on a cookie that authenticates nothing — precisely who #664's invite half exists for. The address lookup is a bare equality where every other path here normalises first.
Your timing oracle is real and I would leave it.
Findings
- blocker —
consumeLink.ts:80unverified manager: link burned, session dead, no message. - should-fix —
requestLink.ts:77case-sensitive email lookup, hidden by the uniform answer. - consider —
consumeLink.ts:51a GET that burns the link; mail scanners prefetch.
Checked: both handlers and all of src/plugins/login/ whole; Managers.ts:22-60; signedToken.ts; requireActiveManager.ts:23; restRequest.ts:48; upsertUserByEmail.ts:26; all 17 specs; the doc diffs.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
From the adversarial review on #847. `Managers.auth.verify` is configured, and Payload's JWT strategy yields no user while `_verified` is false. Neither route read the flag, so an unverified manager got the mail, `consume-link` burned the link, minted a cookie and redirected to `/admin` — which bounced them to the login form with no message, their one link spent and the 60-second throttle refusing the obvious retry. Setting the flag is the answer rather than refusing at `request-link`: following a link delivered to the stored address is the same proof of ownership the verify mail asks for, and #664's invited managers are unverified by definition. Every fixture in the spec passed `_verified: true`, which is why the lane could not see this. The new case builds an unverified manager and spends the cookie — it fails with `user` undefined when the flag is not written. Refs #837 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Rk89KqrRni8eWSqK7vqypB
From the adversarial review on #847. Payload's `email` base field lowercases and trims on every write, so the stored column is normalised and the lookup's bare equality was not: a manager typing `[email protected]` matched nothing. Because the answer is deliberately identical to an unknown address, they got no mail and no signal, every time they tried. `upsertUserByEmail` and Payload's own `/login` both normalise before the same shape of query. Trimming as well as lowercasing mirrors the stored value exactly, so a pasted trailing space stops being a 400. Refs #837 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Rk89KqrRni8eWSqK7vqypB
From the adversarial review on #847. Link-scanning mail security fetches every URL in an inbound message, so a scanner can consume the link before the recipient clicks, and the throttle then refuses the obvious retry. No machinery here — the recipients' mail providers decide whether this is worth an interstitial page, and that call is the reviewer's. The docblock records what to check first when a manager reports an invalid link. Refs #837 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Rk89KqrRni8eWSqK7vqypB
|
Addressed the adversarial review: three threads, three commits, pushed as b593218. Adopted
Left open, for @Ardnived
Both fixes were reintroduced at their real site and watched go red. Lean gate green, and 19 targeted integration specs pass. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Addresses both review threads on #847. The plugin took no `collections` option and keyed on a literal `managers`; the endpoint definitions sat beside that one collection while the plugin only wired them. `loginPlugin({ collections: [...] })` now builds a `request-link` / `consume-link` pair per entry, and both definitions moved into `src/plugins/login/endpoints/` as factories — there is no single collection to park them beside once more than one can be served. The option is a list of configs, not of bare slugs, and that is the whole difference between a knob and a footgun. Three things in these routes belong to the collection, not the plugin: the eligibility predicate (`type === 'inactive'` is a `managers` enum), the envelope sender, and the mail template. A bare slug list would accept a second collection and mail it manager branding under a predicate its schema has no field for. `LoginCollectionConfig` requires `mail` and takes `isEligible`, `select` and `redirectTo`, so a second slug cannot be added without supplying what makes it correct. `managersLogin` holds those values beside Managers. Token audiences stay `manager-signin` / `manager-invite`. Cross-collection replay is already refused by the `collection` claim, which `consume-link` now compares against its own configured slug, so renaming the audiences would churn a pinned security constant to no effect. `isEligible` is re-checked on consume as well as on request: an account deactivated while a link was outstanding must not be able to spend it. That was already true and stays true. Behaviour for `managers` is unchanged — all 19 specs in manager-magic-link.int.spec.ts pass untouched, as do login-session, managers-access and role-based-access (85 more). tests/unit/login-plugin.spec.ts is new: it folds the plugin by hand, before sanitizeConfig, where `endpoints` is still undefined. Each of its six assertions was watched fail at its defect's real site — replacing rather than appending endpoints, dropping the field, throwing on an unnamed collection, materialising one for an unmatched option slug, serving only the first entry, and dropping the empty/disabled guard. The unmatched-slug assertion was vacuous in its first form, passing against an empty config that never reached the lookup, and is folded against a real collection now. Refs #837 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019vpHpugPJ1hp7iaBXSiH2E
Both docs stated the rule this PR's review reversed. `docs/rules/endpoints.md` said to key on the literal slug because a handler branching on a collection-specific enum, sender or template cannot honour a slug parameter — true, and now the reason the option carries those three as configuration rather than the reason not to have one. The rule is restated as the choice it really is: hard-code the target and say so, or pay for the promise a slug option makes. `src/AGENTS.md` described the barrel stopping short of endpoints that live beside their collection. They live in the plugin now, and the barrel still stops short of them, for a different reason: loginPlugin is their only caller. Refs #837 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019vpHpugPJ1hp7iaBXSiH2E
The two handlers are `requestMagicLink` and `redeemMagicLink`; their routes were still `/request-link` and `/consume-link`. @Ardnived confirmed no links have been delivered, so nothing outstanding carries the old paths, and #837 names the request path only as a placeholder rather than pinning it. `REQUEST_LINK_PATH` and `CONSUME_LINK_PATH` follow, as does the integration spec's `CONSUME_PATH`, which otherwise named a redeem route "consume". Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0164fYKRinsznYoRRuXrnoTA
|
Fifth round — the route paths, pushed as 0ace32d. Adopted
⚠ Three earlier rounds defended the old paths by claiming #837 published them. It does not — its checklist spells the route Settled
Still yours — inline send versus a job, a bare slug list, the timing oracle, and the GET that burns a link. Lean gate green. 19 magic-link integration specs pass. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Link-scanning mail security (Defender Safe Links, Proofpoint) issues a GET on every URL in an inbound message before its recipient sees it. The redeem route was a GET that cleared `magicLinkIssuedAt`, so a scanner spent the manager's one use, and `request-magic-link`'s 60-second throttle then refused the obvious retry: no session and no second mail. The burn moves to POST. A second handler holds GET on the same path and renders a plain form that submits it. Scanners do not POST and do not click, so the link survives the scan and its owner still spends it in one action. The form carries no script and no refresh, which is the whole defence — anything that submitted it automatically would restore the hazard. The GET verifies the token so a dead link reads as a sentence, and that check touches no document: a scanner's fetch stays free of consequence. Both handlers answer a browser now, so their refusals are HTML pages rather than error envelopes. `tests/unit/login-plugin.spec.ts` asserts `<method> <path>` rather than the path alone, because which verb each handler answers is now the security property. All three new assertions were watched fail at their real defect sites: the GET wired to the burn, and the page offered without verifying. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RhggSG55nFwfC3HyV9bPRb
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RhggSG55nFwfC3HyV9bPRb
|
Sixth round — the mail-scanner hazard, pushed as 36e48f5. Adopted
Settled
Still yours — a bare slug list, the timing oracle, and the project branding that contradicts #483. Lean gate green. Full 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
The GET on /redeem-magic-link existed only to render HTML, which is what made the plugin own two pages in a visual language nothing else on the site speaks. Moving the address instead of the method keeps the whole scanner defence: the mail now points at `requestPagePath`'s own `(frontend)` page, which reads the token and writes nothing, and the burn stays behind that page's form on a method no scanner uses. So `page.ts` and `confirmMagicLink` both go, `requestPagePath` becomes required — it is the address in the mail — and every refusal redirects to `?error=expired|invalid`, the spelling #838 asked for and #847 dropped. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018HjG73fjLEx2FhsBgWsMXf
…can post links (#854) * feat(email): send preview mail over Mailpit's HTTP API, so a routine can post links A Claude routine reaches the network only through an HTTPS proxy, so the preview scripts' SMTP send to Mailpit's TCP proxy timed out there (#807) and no loop PR could carry an email preview link (#847, #853). The capture transport now posts to Mailpit's `POST /api/v1/send` instead, authenticated with a send-only `MAILPIT_SEND_AUTH` (Mailpit's `MP_SEND_API_AUTH`), falling back to `MAILPIT_UI_AUTH` while no send credential is configured. The scripts no longer read `SMTP_URL`; the app still sends through it. Also records where previews get `SMTP_URL` from: production's service, where it is inert, since Railway copies production's variables into every PR environment. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * refactor(email): send preview mail with the Mailpit login, not a send-only one Mailpit holds nothing a read login could leak: a preview's database has no production rows, and production mail goes to Resend. So one credential, MAILPIT_UI_AUTH, serves the scripts, the reviewer and the routine, which can now open its own previews too. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Summary
createSessiongeneralises pastmanagers, per @Ardnived's decision on #846, and refuses a collection that cannot hold a session.managers.magic_link_issued_at. No behaviour changes for anyone who does not request a link.Changes
src/plugins/login/—loginPlugin(the field plus all three endpoints, per collection itscollectionsoption names),endpoints/{requestMagicLink,confirmMagicLink,redeemMagicLink}.ts(the handlers, as factories),page.ts(the confirmation page, and the refusals a browser gets),mail.ts(the sign-in message every served collection gets),types.ts(LoginCollectionConfig),token.ts(the two link kinds as separate JWT audiences), andsession.tsgeneralised tocreateSession(payload, slug, id).src/collections/Managers/login.ts— the two things onlymanagerscan answer: theinactivepredicate, and which project brands the mail.src/emails/SignInLinkEmail.tsx— the message.magicLinkIssuedAtcarries three jobs at once, which is the design's load-bearing economy: it is the 60-second send throttle, it is the nonce the redeem route matches exactly, and clearing it is what makes a link single-use and what a fresh request does to the outstanding one.Preview
admin.hidden, so nothing should appear here; that is the assertion.Migration
src/migrations/20260923_161630_add_manager_magic_link.tsmanagers.magic_link_issued_at(timestamp(3) with time zone, nullable). No data transformed, no rows touched.downdrops the column, and nothing else reads it.Test results
pnpm lint,pnpm typecheck,pnpm typecheck:tests,pnpm test:unit(161 files, 2179 tests)tests/int/manager-magic-link.int.spec.ts, pluslogin-session,role-based-access,managers-access, and the five specs that usecreateRestClientAs— all passedpnpm test:int: ✓ 85 files, 1406 testsNotes for reviewer
Sixth review round: the mail-scanner hazard is closed. The
GETthat spent the link is now a confirmation page, and the burn moved toPOST /api/<slug>/redeem-magic-link(36e48f5). Defender Safe Links and Proofpoint fetch links; they neither POST nor click, so a scan costs the recipient nothing and the owner still signs in with one click.The page carries no script and no meta refresh, and that is the defence rather than a style choice — anything that submitted the form by itself would hand the link straight back to the scanner. The integration spec asserts their absence for that reason.
Two consequences worth naming. The
GETverifies the token, reading no document, so a dead link says so instead of offering a button that fails. And both handlers now answer a browser, so their refusals are HTML pages rather than error envelopes.tests/unit/login-plugin.spec.tsasserts<method> <path>instead of the path alone, since which verb each handler answers is now the security property.Fifth review round: the route paths.
/request-linkand/consume-linkare now/request-magic-linkand/redeem-magic-link(0ace32d), matchingrequestMagicLink.tsandredeemMagicLink.ts.REQUEST_MAGIC_LINK_PATHandREDEEM_MAGIC_LINK_PATHfollow.⚠ Three earlier rounds defended the old paths on a claim that was wrong. They said #837 published them. It does not: its checklist spells the route
<request path>, a placeholder. @Ardnived's "no links have been delivered yet" removed the other reason, and the rename cost one commit.Of the two threads that asked whether a piece of this should exist at all, both are now settled:
{ok:true}for every outcome, and the token reaches only the stored address. Payload's ownPOST /forgot-passwordis anonymous for the same reason.sendEmailcanonical, or should this be a job? Leave as is, per your call.payload.sendEmailis the email adapter's one entry point, and Payload's own verify and reset mail call it inline. Queueing this send stays available, and it is the same decision as the timing oracle below rather than a separate one.The mail lives in the plugin.
src/plugins/login/mail.tsrendersSignInLinkEmailand the subject for every served collection, and a collection overrides either half through agenerateEmailHTML/generateEmailSubjectpair shaped exactly like the oneManagers.auth.verifyalready takes.LoginMailis gone, and the envelopeFromleft the config surface with it: every collection this plugin can serve is an auth collection, soMANAGER_EMAIL_FROMis the sender by construction.⚠ One divergence worth your eye. The mail is branded for the recipient's
currentProject, per review — but #483 decided the opposite for the verify and reset mail, which take the default brand whoever the recipient is. The two auth paths now disagree. It is noted at the call site; say which way you want it and both can follow.An entry is a config, not a bare slug, and that is the one thing left to check.
slugis the only required member now: the plugin renders and addresses the mail itself, so an entry carries only what reads a field the plugin cannot know the name of —isEligibleandproject— plus theselectthat makes those two readable. That thread stays open for your veto; a bare list is a smaller change from here than it was.Token audiences stay
manager-signin/manager-invite. Cross-collection replay is already refused by thecollectionclaim, which the redeem route compares against its own configured slug, so renaming them would churn a pinned security constant to no effect.One open security finding, not fixed.
request-magic-linkanswers identically for every outcome in status, body and headers — but not in elapsed time. An unknown address does one indexed read; a real one also writes, signs, renders and sends inline, which is hundreds of milliseconds to seconds. That is a readable account-enumeration oracle for an unauthenticated caller, and the fact it discloses ("this address is an active manager") is worth more to a phisher than a raw address list. Two fixes exist and both cost something the ticket decided against: hand the send to the queue (reopens the ticket's own open question, which resolved to inline), or pad the handler to a fixed floor above p99 send time (a multi-second hold on an anonymous endpoint). Left as-is with the trade stated in the handler's docblock — your call.The ticket's open question is answered inline, matching the verify and reset mail
Managers.authalready builds withrenderEmail, and keeping the throttle meaningful.Manual verification
POST /api/managers/request-magic-linkwith your own manager address, then follow the emailed link — it should show a confirmation page, and its button should land you authenticated in/admin.curlthat same emailed link, which is what a scanner does. It must answer 200 with a form and noSet-Cookie, and the link must still work afterwards.POSTthe request endpoint with an address no manager holds, and diff the response against the success case. Status and body must be byte-identical.GET /api/managers/meafter signing in that way, at two locales, and confirmrolesis the per-locale record rather than a flat array.Detail
Every load-bearing assertion was watched fail at its defect's real site, per
docs/rules/testing-reqs.md:request-magic-linkanswersetProjectsurvivesendpoints:replaced, not appendedmagicLinkIssuedAtis not hand-writableupdate: () => falseremoved_verified: truedropped from the burn.toLowerCase()removedendpoints:replaced, not appendedgetEmailBrand(project)reverted togetEmailBrand()managersLoginresolves that project off the documentprojectresolver removedmanagersmanagersLogingiven agenerateEmailSubjectof its ownGETspends nothingGETwired back to the burnGET's own token check removedThe last three rows are the scanner defence (36e48f5). Reverting the whole thing — the emailed
GETwired back to the burn, with noPOST— turns eleven specs red, so the isolated form was used instead: thePOSTleft in place and a secondGETpointed at the same handler. Exactly the two new scanner assertions fail there, which is what proves they test the burn rather than the feature.The wiring rows are
tests/unit/login-plugin.spec.ts(0d12fac); the three mail rows aretests/unit/login-mail.spec.ts(522be0d). The wiring spec's unmatched-slug assertion was vacuous in its first form — folded against an empty config, it never reached the lookup it was written for, and passed with the defect present. It folds against a real collection now.One assertion is pinned as a property rather than a mechanism, and says so in the spec: a link token presented as a session cookie is refused by two independent accidents of Payload's
JWTAuthentication— the claim isuserIdnotid, and there is nosidfor the session checkmanagersinherits. Measured: adding anidclaim alone does not flip it. It is not vacuous — the cookie case above it reachesuser.idthrough the same client and read path.Why the confirmation page carries the token in the form's action. A custom Payload endpoint is handed no parsed form body —
parseBodyreads JSON, which a form submit does not send — so thePOSThandler readsreq.query.token, exactly as theGETdid. The URL is the one the email already delivered, so nothing new is exposed by it.page.tssendsCache-Control: no-store,Referrer-Policy: no-referrerandX-Robots-Tag: noindexfor the same reason the credential is in the URL at all.tests/utils/restRequest.tsnow returns{}for a body that is not JSON rather than throwing. The redeem route answers a browser with HTML, andrawis what the spec asserts against there.What the review passes changed, beyond the slug. Both reads gained a bounded
select; the email's "valid for" string derives fromSIGNIN_TOKEN_TTL_MSrather than restating it (it would otherwise have silently lied after a TTL change); the send routes header text throughemailSafeText, as six of the seven other senders do; andcreateAnonRestClient/createRestClientWithAuthjoinedtests/utils/restRequest.tsinstead of the spec rebuildinghandleEndpointsthree times. The endpoints'Candidateshadow types are gone: a structuralLoginDocumentreplaces them, since a shape tied to one collection's generated type would make every second collection a cast.managersLogin.isEligiblestill readsManager['type'], so renaming that enum option upstream fails the typecheck rather than quietly admitting every manager.LoginDocumentandSessionDocumentare not overlapping systems, which a thread asked. They narrow two different reads: the first is what the endpointsselect, the second is whatgetFieldsToSignneeds offcreateSession's ownfindByID—sessions, which the endpoints never select. Each docblock now names the other.Declined review findings, with reasons. The invite half of
token.tshas no production caller and three reviewers suggested dropping it — it is explicit ticket scope (manager-invite, 7 days) and an acceptance criterion, so it stays.hasSessionsFieldscans for the field rather than readingauth.useSessions/auth.disableLocalStrategy, becausedisableLocalStrategy: { enableFields: true }is a shape where the flags and the field disagree, and the flag reading would refuse a collection that does havesessions. The redeem route reads the account and thencreateSessionreads it again: threading a pre-read document in would re-open the exact hazard that function's docblock exists to close (a caller supplying aselect-narrowed doc silently drops asaveToJWTfield), and sign-in is not a hot path. Neither write threadsreq: the link must be burned even if minting then fails, and a shared transaction would roll the burn back and leave the link live.No email preview links. There is no
scripts/preview-*-emails.tscovering manager auth mail, andSMTP_URLis unset here, so nothing could be posted to Mailpit. The template is asserted instead by the integration spec, which reads the rendered HTML back and extracts the link from it — the same shapemanager-verification.int.spec.tsuses, and for the same reason: reading the token off the row would pass even if the template embedded no link at all.One flake observed, then fixed. The first full
pnpm test:intrun faileduser-submissions-review-lifecycle.int.spec.tson an image-upload fixture (ValidationError: filename).staticDiris shared across suites, so two concurrent uploads read the same directory before either writes and land on the same-Nsuffix. Fixed in ebe812e by naming fixture uploads uniquely.Not registered in the OpenAPI shim, deliberately:
docs/rules/endpoints.mdrequires it for public, client-facing endpoints, andmanagersis admin-only and in no project.tests/unit/openapi-custom-endpoints.spec.tsasserts a fixed list, so nothing fails — confirmed rather than assumed.Closes #837
🤖 Generated with Claude Code
https://claude.ai/code/session_01RhggSG55nFwfC3HyV9bPRb