Repository navigation
feat(auth): the logged-out sign-in pages for managers - #849
Conversation
`CardShell`, the button styles and the tone emblems existed twice and were imported a third time across route folders — `registrations/feedback/` reaches into `events/verify/` for them today. A route folder is not a module home, and the manager sign-in page (#838) would have been the third copy. `_components/` is a private folder, so Next excludes it from routing. Each page keeps its own outcome and tone types: `CardTone` is the widest set the emblem map covers, and a page narrows it to what it can actually conclude. Refs #838 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019zvVfM6Wp8JDjW6mimH28T
The magic-link endpoints (#837) had no human surface: a manager could not ask for a link, and every refusal was a dead end that said "request a new sign-in link" while offering no way to do it. `/managers/signin` is that page, and it never 404s — its neighbours do, because a genuine token is the only way to reach them, but this one is published and hiding it would take away the retry path. `issueMagicLink` is the request endpoint's body, now exported and called by the Server Action too, so the 60-second throttle, the eligibility refusal and the uniform answer have one implementation. That throttle is the only in-app bound on per-account link volume, so a second copy of it is the one worth refusing. `magicLinkEmailSchema` travels with it: normalisation living in only one caller would let the other miss a match that the uniform answer then hides. `requestPagePath` on the served collection wires the rest — both refusal pages gain a "Request a new link" button, and the admin login form gains the control. `loginPlugin` spreads `admin` and `admin.components` rather than assigning them: replacing either would silently delete the project selector, the custom nav and both custom views. Refs #838 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019zvVfM6Wp8JDjW6mimH28T
… control Ten integration assertions on the Server Action, plus four unit assertions on the plugin's admin wiring. The assertions that matter cross the two callers: a link issued through the endpoint must throttle the action, and the reverse. A page that re-implemented the send would satisfy every single-caller assertion and fail those two. Each load-bearing assertion was watched fail at the defect's real site — the action re-implementing the send, the action disclosing an unknown address, the refusal pages dropping the retry link, `components` assigned rather than spread, and the `admin.user` and `requestPagePath` gates removed one at a time. The admin spread is asserted in the unit lane, not the integration one: the test config declares none of the other component slots, so "every existing entry survives" is invisible there. The unit spec folds a config that carries all six. No rows were added to `client-bundle-safety`: its entries are derived, and both new client files (`SignInForm.tsx`, `RequestSignInLink/index.tsx`) are already in the set — verified, not assumed. Refs #838 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019zvVfM6Wp8JDjW6mimH28T
Refs #838 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019zvVfM6Wp8JDjW6mimH28T
The new helper landed between the JSDoc and the function it documents, so the `@example` showing how to register the plugin was describing a private helper. Refs #838 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019zvVfM6Wp8JDjW6mimH28T
`endpoints.md` and `collections/AGENTS.md` both said the plugin owns two endpoints; #847 shipped three, splitting the redeem path by method. Corrected while recording what #838 adds: the human surface, `requestPagePath` as the one spelling of its route, and the barrel's one exported handler body. Refs #838 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019zvVfM6Wp8JDjW6mimH28T
Structural, from the altitude lens: `issueMagicLink` and `magicLinkEmailSchema` move out of the endpoint that used to hold them into `issueMagicLink.ts`, a sibling of `session.ts` — the exact precedent, work with two callers in its own module. The endpoint is wiring again, so the barrel's "no endpoint factories" rule needs no exception, and the paragraph defending one is deleted rather than kept. The retry link stops being absolutised. `requestPagePath` is site-absolute and these pages are served from that origin, so `getServerUrl()` bought nothing and was duplicated in both endpoints. `noticePage` now takes the path and refuses anything that is not one — a `javascript:` or off-origin value behind a button on an unauthenticated page is the shape worth closing before a second `LoginCollectionConfig` exists, not after. Seven unit assertions pin it, each watched fail with the guard and the escaping removed in turn. `expired`/`invalid` move inside the factory closure, so none of the six refusals can drop the retry link by forgetting an argument. Smaller: the sign-in form was a fourth copy of the card prompt typography, so `cardHeading`/`cardLead` join the shared module; `SignInOutcome` becomes a union because the refusal arm's `title` never reached a screen; `VerifyTone` aliases `CardTone` rather than respelling it; the `PageAction` pass-through re-export goes; and `MANAGER_SIGNIN_PATH`'s comment stops claiming an enforcement that does not exist — nothing checks a constant against a filesystem route. Refs #838 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019zvVfM6Wp8JDjW6mimH28T
|
🤖 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 size of its ticket: the page, the issueMagicLink extraction and the CardShell move were all specified, and the move is net-neutral. The two cross-caller throttle assertions are there, and they are what matters.
One deviation needs a call. #847 made ?error= dead, so three criteria are met by substitution: a refused link lands on the plugin's bare system page, which now offers a button back to the branded one. The ticket wanted the refusal itself here. Cheaper, and it leaves one flow in two visual languages.
Findings — none blocking.
- should-fix — the
retryPathguard defends a module constant against nobody, and/\hostslips through (page.ts:79) - should-fix — the tab says "Sahaj Cloud", the card says "WeMeditate Web" (signin/page.tsx:9)
- consider — the substitution above (redeemMagicLink.ts:53)
- consider —
VerifyTonealiasesCardTone(VerificationCard.tsx:15)
Checked: #838 and #847 against the diff; loginPlugin.ts, page.ts, issueMagicLink.ts and the card pages whole; both new specs.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`retryPath.startsWith('//')` misses `/\host`, which every browser
normalises to `//host` — so an off-origin URL could still reach the
button on an unauthenticated refusal page. Test the second character
for either slash instead.
The new spec row was watched fail against the old guard.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013feAsMqwDVNBZeLBBeMtF5
The tab said "Sahaj Cloud" while the card header below it rendered `brand.productName` — "WeMeditate Web" for the default project. Both neighbours suffix the tab with the brand their card wears; this one now derives it from the same source rather than naming a product that exists nowhere else. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013feAsMqwDVNBZeLBBeMtF5
On main `VerifyTone` was its own union. The CardShell extraction left it aliasing `CardTone` with one use, in this file — it narrows nothing, and nothing outside imports it. `UnsubscribeTone` still earns its name by dropping `warning`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013feAsMqwDVNBZeLBBeMtF5
|
Addressed the adversarial review. Three commits, pushed as 4ed1f49. Adopted
Asked
Lean gate green. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
🚅 Deployed to the SahajCloud-pr-849 environment in sahajcloud
1 service not affected by this PR
|
538a0be turned every refusal into a 302 back to `/managers/signin?error=` and left the path answering `post` only. Four assertions still described the old endpoint: two arms asserted the 400 of the deleted notice page, and both specs predicted a bare 404 for the scanner's GET. A GET there is 403, not 404. With no `get` handler, Payload tries the collection's `findByID` route with `redeem-magic-link` as the id and refuses the anonymous read before any query runs. Either status says the same thing — nothing on this path answered, so nothing was spent — and the stamp assertion beside it is what proves the link survived. The two refusal arms now go through `expectRefused`, which asserts the `Location` as well as the absent cookie, so they check more than the status they replaced. No production code changes. That push could not run the integration lane — no database in that session — so these four were predictions. This one ran it: 1419 tests across 86 files, plus the lean gate. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mc61rWf8amYMZu3d1xR1D7
CardShell wore a brand gradient header over a white card, so a public page was light whatever the reader's system asked for, and the shell could not be reused by the home page — it had a card's shape, not a page's. PublicPage replaces it: a logo, a title and a centred column, nothing else. It takes a title string rather than an EmailBrand, which is what lets the home page wear its own name while the mail-reached pages wear their project's. Colour moves to tokens in styles.css, redefined under prefers-color-scheme: dark. Every page's literals go with it, because one inline hex left behind is a white box on a dark page and nothing fails. The tone accents are lifted rather than reused in the dark block: the light greens and ambers do not carry against the dark surface. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R5nbH1nPpYXvYg7YkwZSwc
Deleting page.ts in 538a0be took its retryPath guard with it, and nothing replaced it. The plugin's two other consumers compose requestPagePath after an absolute origin, so they were never the hazard — but the admin control hands it to RequestSignInLink's `to` unprefixed, where a browser reads a leading /\ or // as an origin and the login form gets an off-origin link. The control is omitted rather than the value repaired: it is a LoginCollectionConfig field, so a served collection can supply any string, and a silently-dropped button beats a working one that points off-site. Three spec rows, each watched fail with the guard removed. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R5nbH1nPpYXvYg7YkwZSwc
|
Pushed ca49df2 and f7d83f2. Lean gate green: lint, both typechecks, 2188 unit tests. Adopted — the layout is done. Found and fixed — deleting ⚠ No browser check here, and no integration lane — no database. CI runs both. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
`main` #849 moved the verify card's styles into the shared `_components/PublicPage`, deleting the block this branch had edited. Took that deletion and carried the one behaviour it would have dropped — `whiteSpace: 'pre-line'` on the outcome message — onto `outcomeMessage` in its new home, so the invalid-data field list still renders one line per field. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SgXW9zAoViUb96gwRhVuDo
The old path shipped in #849, four days before this branch moved sign-in into the admin login view. Production has been mailing `/managers/signin?invite=`, `?token=` and `?link=` URLs since then, so deleting the forward 404s every invitation still inside its 7-day window and every reminder link inside its 10-day one. The manager it was sent to holds no other credential, so there is no way back in for them. This reverts aa4c1dc, which removed the forward on the premise that the old path never shipped. `src/app/(frontend)/managers/signin/page.tsx` is on `main` today. Four comments already said the forward was load-bearing and one of them gave the exact expiry windows; all four were deleted along with it. So the rule moves into a spec that fails when the redirect goes missing or stops being permanent, rather than staying prose a reader has to believe. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QKn3Da33MtvBuuaLrj8jqo
This reverts 4356646. The old page did ship in #849, but production mailed no sign-in link, invitation or reminder link to it before this branch moved sign-in to /admin/login, so no link addresses it and there is nothing to forward. Decided by the maintainer on the PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
/managers/signingives the feat(auth): the login plugin, with magic-link request and consume endpoints #837 magic-link endpoints a human surface: a manager can ask for a link, confirms a delivered one, and every refusal lands back here where the form that fixes it is already on screen.page.tsare(frontend)pages now.Changes
src/plugins/login/magicLinks.ts— new. The mint/throttle/send body, moved out of the request endpoint now that it has two callers, besidesession.tsfor the same reason.src/plugins/login/page.ts— deleted, withconfirmMagicLinkbeside it. The delivered link addresses/managers/signin?token=…, a real page that reads the token and writes nothing; thePOSTbehind its form still burns the link, so the mail-scanner defence is unchanged while theGETis a page./redeem-magic-linkanswerspostonly, and the spec asserts the absent verb.src/app/(frontend)/_components/PublicPage.tsx— new, replacingCardShell. A logo, a title and a centred column: no card, no gradient header. It takes atitlestring rather than anEmailBrand, which is what lets the home page wear its own name while the mail-reached pages wear their project's.events/verify, bothregistrations/pages and the home page all render inside it.src/app/(frontend)/styles.css— colour is tokens, redefined underprefers-color-scheme: dark. Every page's literals moved onto them: one inline hex left behind is a white box on a dark page, and nothing fails. The tone accents are lifted in the dark block rather than reused — the light greens and ambers do not carry against the dark surface.src/plugins/login/loginPlugin.ts— the site-absolute check onrequestPagePath, restored after thepage.tsdeletion dropped it (f7d83f2). See below.Preview
Test results
Notes for reviewer
A regression this branch introduced, found while writing this description and fixed in f7d83f2. Deleting
page.tsin 538a0be took itsretryPathguard with it and nothing replaced it. Two of the three consumers ofrequestPagePathcompose it after an absolute origin and were never at risk — butloginPluginhands it toRequestSignInLink'stounprefixed, so/\evil.example.comwould have put an off-origin link on the admin login form. The control is now omitted for any value that is not site-absolute. Three spec rows, each watched fail with the guard removed.Every thread from your review is now answered, and the layout one is implemented. One remains open by your choice:
requestPagePath, which the page merge made required rather than redundant — it is the address the mail carries.#847 answered both of this ticket's open questions differently from the plan, so three acceptance criteria are obsolete. The ticket specified
consumeLinkredirecting refusals to/managers/signin?error=expired|invalid. #847 instead served its own HTML notice pages from the redeem route. This PR ends up back at the ticket's spelling, reached the other way round: the page owns theGET, so?error=has a caller again.One judgement call still open: the ticket directed
loginPluginto injectafterLoginand spreadadmin.components, and that is what this does. The altitude review argued it belongs as one line inpayload.config.tsinstead, sinceafterLoginis a config-root slot and the plugin is collection-generic. I kept your version — the plugin owning the whole feature means removing it removes the control too, rather than leaving a button pointing at dead endpoints — but the counter-argument is reasonable.Detail
From the adversarial review
retryPathguard lets/\hostthrough. Adopted, then lost, then restored one layer up — see the regression note above. It isisSiteAbsoluteinloginPlugin.tsnow, at the only consumer that does not prefix an absolute origin.VerifyTonealiased the shared tone union. Adopted — deleted; the one use takesPageTone.Dismissed review findings
UnsubscribeCardandVerificationCardinto oneOutcomeCard. Correct that they are now near-identical, but it rewrites two pages this ticket only had to leave working. Follow-up.FeedbackForm's hand-rolled emblem onto the sharedOutcomeBody. ItsfontSizeis 22 againstOutcomeBody's 20, so adopting it would change that page's rendering. Rejected.brandGradientinto@/lib/branding. Follow-up, and smaller now: the gradient is off the page shell and survives only insrc/emails/.On the tests
Every load-bearing assertion was watched fail at the defect's real site, then restored: the action re-implementing the send, the action disclosing an unknown address, the refusal dropping its retry,
admin.componentsassigned rather than spread, theadmin.userandrequestPagePathgates removed one at a time, and the three new site-absolute rows.The two assertions that carry the most weight cross the callers — a link issued through the endpoint must throttle the action, and the reverse. A page that re-implemented the send satisfies every single-caller assertion and fails those two.
On
client-bundle-safetyThe ticket asked for new rows naming this page's action, its form and the admin component. None were added: that spec derives its entries rather than listing them. Confirmed both new client files are in the derived set (93 entries) rather than assuming it.
Also corrected
docs/rules/endpoints.mdandsrc/collections/AGENTS.mdboth described the login plugin's endpoint set; it is two again, now thatconfirmMagicLinkis a page.Closes #838
🤖 Written by the sydevs autonomous loop — see what this is