feat(auth): surface loopback Mailpit guidance without bypassing magic links (#29) - #75
waterbro-8 wants to merge 3 commits into
Conversation
… links Reduce first-time local login hops by pointing at Mailpit and, when the message exists, the newest Auth.js callback. Production and non-loopback inboxes stay closed. The emailed magic link remains the authority. Refs bytefolk#29
waterbro-8
left a comment
There was a problem hiding this comment.
Review
Cannot request-changes on our own PR. CI test failed: e2e sign-in screenshots at 390px and 600px light (3489 px). docker-build passed.
Must fix before merge
- Screenshot regression. Headers changed from
items-center text-centertoitems-start text-left. Unrelated to Mailpit. Revert unless snapshots are intentionally refreshed. - Verify-request does not pass
email, so the magic-link poll never runs on the page after submit. - Hint is off unless
DOC_MAILPIT_URLorDOC_LOCAL_AUTH_HINT=1. Localdoc devmay still not show it. Enable loopback Mailpit by default outside production, keep production / non-loopback /DOC_LOCAL_AUTH_HINT=0closed.
Will push a follow-up on this branch.
Revert the sign-in header alignment so e2e baselines stay valid. Read email from the verify-request query string, and enable loopback Mailpit guidance by default outside production.
E2E sign-in baselines run against next dev. Show loopback Mailpit guidance only on verify-request, after the email has been submitted.
|
Follow-up: Mailpit hint is only on verify-request (after submit). Sign-in e2e still uses |
Bindy-lbb
left a comment
There was a problem hiding this comment.
LGTM. Well-scoped local DX improvement. The mode-gating logic (production / DOC_LOCAL_AUTH_HINT=0 / non-loopback URL all disable) is solid and testable via DI on the env object. The Mailpit polling interval (1.5s) with cleanup is reasonable. Magic-link regex extraction with & normalization handles HTML mail correctly. i18n messages for both en/zh-cn are present. Documentation in RUN_LOCAL.md is clear. No security concerns — production path is never enabled.
sun-970
left a comment
There was a problem hiding this comment.
Review — Approve
Head d0162f6. MERGEABLE. CI test / docker-build / dependency review / Scorecard green.
Mode gating is correct and testable: production, DOC_LOCAL_AUTH_HINT=0, and non-loopback Mailpit URLs all disable. Outside production, loopback Mailpit (default http://localhost:8025) is on. Magic-link assist only fetches that loopback inbox (no SSRF to an arbitrary host). extractMagicLink is limited to Auth.js callback URLs. Production never enables this path. i18n en/zh-cn and RUN_LOCAL.md are present.
Non-blocking
- Sign-in still calls
signIn(...)without puttingemailon the verify-request URL. The Mailpit link still shows; the auto “open latest magic link” poll only runs if?email=is already on that page. - The emailed magic link remains the authority, as documented.
Summary
Refs #29.
Local/dev first-time login currently requires knowing Mailpit exists. This adds a mode-gated hint:
http://localhost:8025).DOC_LOCAL_AUTH_HINT=0, and non-loopback Mailpit URLs never enable this.Test plan
npx vitest run src/__tests__/lib/local-auth-guidance.test.ts src/__tests__/api/local-auth-routes.test.ts src/__tests__/components/signin-page.test.tsx— 13 tests passnpm run lintOut of scope