Skip to content

feat(auth): email reset/verify links over SMTP instead of logging tokens - #493

Merged
datvt243 merged 1 commit into
stagingfrom
feature/461-password-reset-email
Nov 19, 2026
Merged

datvt243 merged 1 commit into
stagingfrom
feature/461-password-reset-email

Conversation

@datvt243

Copy link
Copy Markdown
Owner

32cbe39 feat(auth): email reset/verify links over SMTP instead of logging tokens

Closes #461

Reset and verification links carried live tokens in logger.info, so anyone with log access could take over an account.

- src/services/mail.ts (new): sendAuthLinkEmail via Nodemailer SMTP (SMTP_HOST/PORT/USER/PASS, MAIL_FROM, APP_URL), plain text in the ?lang= language, 10s SMTP timeouts; SMTP_HOST or APP_URL unset -> dev logs the link, prod warns without it and sends nothing
- src/auth/auth.service.ts: register and forgot-password email the link fire-and-forget (no response-time difference for registered emails, a failed send keeps the generic response and is logged by message only); prod forgot-password logs only the candidate id
- src/locales/vi.ts, en.ts: mail subject/body strings
- src/utils/passwordReset.ts, emailVerification.ts, src/routers/api/v1/auth.route.ts: stale stub comments/summaries updated
- tests: auth.service.test.ts mocks the mail module (send asserted, no token in prod logs, failure path, no await); new services/mail.test.ts with nodemailer mocked
- package.json/package-lock.json: nodemailer ^10.6.0 (6.x had open high advisories), @types/nodemailer
- .env.example, CLAUDE.md, .claude/rules/api.md, README.md: new env vars, stub wording removed

npm test: Test Suites: 76 passed, 76 total / Tests: 801 passed, 801 total
npm run build: exit 0 (tsc typecheck); lint 273 problems (<= 274 baseline), none new in changed files

Node: email-auth-links (SEALED)
Evidence: agent-hub/evidence/verifier/2026-11-19/email-auth-links-seal.md

Closes #461

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@datvt243
datvt243 merged commit 6e21b45 into staging Nov 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant