Skip to content

feat(auth): the logged-out sign-in pages for managers - #849

Merged
sydevs-bot merged 17 commits into
mainfrom
claude/feat-838-managers-signin
Sep 25, 2026
Merged

sydevs-bot merged 17 commits into
mainfrom
claude/feat-838-managers-signin

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • /managers/signin gives 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.
  • The page's Server Action and the request endpoint run one shared body, so the 60-second throttle — the only in-app bound on per-account link volume — has a single implementation.
  • The login plugin renders no HTML at all. Both halves of the old page.ts are (frontend) pages now.
  • Every public page shares one minimal layout, and it follows the reader's colour scheme.
  • The admin login form gains an "Email me a sign-in link" control. Passwords are untouched.

Changes

  • src/plugins/login/magicLinks.ts — new. The mint/throttle/send body, moved out of the request endpoint now that it has two callers, beside session.ts for the same reason.
  • src/plugins/login/page.ts — deleted, with confirmMagicLink beside it. The delivered link addresses /managers/signin?token=…, a real page that reads the token and writes nothing; the POST behind its form still burns the link, so the mail-scanner defence is unchanged while the GET is a page. /redeem-magic-link answers post only, and the spec asserts the absent verb.
  • src/app/(frontend)/_components/PublicPage.tsx — new, replacing CardShell. A logo, a title and a centred column: no card, no gradient header. 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. events/verify, both registrations/ pages and the home page all render inside it.
  • src/app/(frontend)/styles.css — colour is tokens, redefined under prefers-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 on requestPagePath, restored after the page.ts deletion dropped it (f7d83f2). See below.

Preview

Test results

  • Lean gate on f7d83f2: ✓ lint, typecheck, test-suite typecheck, 2188 unit tests
  • ⚠ The integration lane has not run in a session since 538a0be — no database available here — and three of its specs changed on this branch. CI is their first run.
  • ⚠ The layout change has no local browser verification. Dark mode, the centred column and the home page's new chrome are asserted by nothing but the preview above.

Notes for reviewer

A regression this branch introduced, found while writing this description and fixed in f7d83f2. Deleting page.ts in 538a0be took its retryPath guard with it and nothing replaced it. Two of the three consumers of requestPagePath compose it after an absolute origin and were never at risk — but loginPlugin hands it to RequestSignInLink's to unprefixed, so /\evil.example.com would 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 consumeLink redirecting 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 the GET, so ?error= has a caller again.

One judgement call still open: the ticket directed loginPlugin to inject afterLogin and spread admin.components, and that is what this does. The altitude review argued it belongs as one line in payload.config.ts instead, since afterLogin is 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

  • The retryPath guard lets /\host through. Adopted, then lost, then restored one layer up — see the regression note above. It is isSiteAbsolute in loginPlugin.ts now, at the only consumer that does not prefix an absolute origin.
  • The tab says "Sahaj Cloud", the card says "WeMeditate Web". Adopted — the title derives from the same brand the page header renders.
  • VerifyTone aliased the shared tone union. Adopted — deleted; the one use takes PageTone.

Dismissed review findings

  • Merge UnsubscribeCard and VerificationCard into one OutcomeCard. Correct that they are now near-identical, but it rewrites two pages this ticket only had to leave working. Follow-up.
  • Move FeedbackForm's hand-rolled emblem onto the shared OutcomeBody. Its fontSize is 22 against OutcomeBody's 20, so adopting it would change that page's rendering. Rejected.
  • Hoist brandGradient into @/lib/branding. Follow-up, and smaller now: the gradient is off the page shell and survives only in src/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.components assigned rather than spread, the admin.user and requestPagePath gates 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-safety

The 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.md and src/collections/AGENTS.md both described the login plugin's endpoint set; it is two again, now that confirmMagicLink is a page.

Closes #838

🤖 Written by the sydevs autonomous loop — see what this is

`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
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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-849 September 24, 2026 05:21 Destroyed
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 24, 2026
@sydevs-bot

sydevs-bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running
CI fix 2

recent dispatches
  • 13:33Z address-review · attempt 1 · session · done
  • 13:33Z address-review · attempt 1 · session
  • 04:19Z fix-ci · attempt 1 · session · done
  • 04:19Z fix-ci · attempt 1 · session
  • 04:01Z fix-ci · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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 retryPath guard defends a module constant against nobody, and /\host slips 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 — VerifyTone aliases CardTone (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

Comment thread src/plugins/login/page.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 24, 2026
`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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-849 September 24, 2026 05:46 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Addressed the adversarial review. Three commits, pushed as 4ed1f49.

Adopted

  • The retryPath guard — /\evil.example.com passed it, since browsers read /\ as //. Now tested for either slash, with a spec row watched fail first. I kept the guard: requestPagePath is a LoginCollectionConfig field, not a module constant.
  • The tab name — it said "Sahaj Cloud" while the card header said "WeMeditate Web". Both now derive from the brand.
  • VerifyTone — deleted, line 77 takes CardTone.

Asked

Lean gate green. manager-signin-page and manager-magic-link re-run, 32 passed.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 24, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review September 24, 2026 05:58
@sydevs-bot
sydevs-bot requested a review from Ardnived September 24, 2026 05:58
@railway-app

railway-app Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-849 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Sep 25, 2026 at 1:47 pm UTC
1 service not affected by this PR
  • mailpit

Comment thread src/plugins/login/magicLinks.ts Resolved
Comment thread src/plugins/login/page.ts Resolved
Comment thread src/plugins/login/types.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed awaiting labels Sep 24, 2026
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. awaiting labels Sep 25, 2026
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
@sydevs-bot sydevs-bot added awaiting bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. awaiting labels Sep 25, 2026
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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-849 September 25, 2026 13:40 Destroyed
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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-849 September 25, 2026 13:44 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Pushed ca49df2 and f7d83f2. Lean gate green: lint, both typechecks, 2188 unit tests.

Adopted — the layout is done. CardShell is _components/PublicPage.tsx: a logo, a title, a centred column, no card and no gradient. It takes a title string rather than an EmailBrand, so the home page wears its own name and renders inside it too, with events/verify and both registrations/ pages. Colour is tokens in styles.css, redefined under prefers-color-scheme: dark.

Found and fixed — deleting page.ts in 538a0be dropped its site-absolute guard. loginPlugin hands requestPagePath to the admin control unprefixed, so /\evil.example.com put an off-origin link on the login form. Restored as isSiteAbsolute, three rows watched fail.

⚠ 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

@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 25, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Sep 25, 2026
Merged via the queue into main with commit cb67eef Sep 25, 2026
22 of 23 checks passed
@sydevs-bot
sydevs-bot deleted the claude/feat-838-managers-signin branch September 25, 2026 17:16
sydevs-bot pushed a commit that referenced this pull request Sep 25, 2026
`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
sydevs-bot pushed a commit that referenced this pull request Sep 29, 2026
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
Ardnived added a commit that referenced this pull request Sep 30, 2026
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]>

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-849 — f7d83f20 Deployed Sep 25, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

feat(auth): the logged-out sign-in pages for managers

3 participants