Skip to content

feat(auth): send trial activation emails after approval - #259

Merged
mirror29 merged 3 commits into
mainfrom
codex/trial-activation-email
Nov 16, 2026
Merged

mirror29 merged 3 commits into
mainfrom
codex/trial-activation-email

Conversation

@mirror29

@mirror29 mirror29 commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Send an activation email to the applicant's stored address after an administrator approves a trial or regenerates its link. Preserve approval and the manual link fallback if SMTP fails; rejected and conflicting reviews do not send mail. Treat the stored recipient as one address rather than an address list.

Validation

  • Dashboard: 214 tests passed; final mail/review tests: 13 passed.
  • Production build and TypeScript passed; final CI rebuild required after SMTP deadline and locale fixes.
  • Evolver: 291 passed, 77 skipped. Ruff passed for all five services. Consistency passed with existing warnings.
  • Paper CI suite passed on the prior revision (backend is unchanged). Local full runs hit shared-schema and pool/timing interference; all 13 auth/waitlist tests passed.
  • Orchestration code is unchanged from main. Its typecheck/test and agent-eval CI jobs passed, confirming local subprocess failures were host-specific. Final-head CI is required before merge.
  • Independent security review completed; recipient parsing concern reproduced and fixed.
  • Production SMTP authentication verified without sending mail. Real UI approval/delivery verification follows deployment.

Documentation

Document automatic delivery, 48-hour expiry, failure fallback, and SMTP deployment configuration. Credentials remain outside version control and logs.

Review decisions

  • SMTP credentials remain server-only in the existing authenticated BFF, which already owns service JWT, database, and model-configuration decryption access. This does not mount the shared environment file or expose secrets through client bundles; moving delivery to another service is a separate architecture change.
  • Delivery waits at most 15 seconds so the administrator receives a truthful SMTP result. Failure preserves manual recovery; no unreliable fire-and-forget work is used.
  • Existing registration stores no applicant locale. The initial email deliberately includes both supported UI languages and does not force the activation redirect locale; localized applicant preferences can be added separately.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Deploying inalpha-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: 33c6f5d
Status: ✅  Deploy successful!
Preview URL: https://22c1975b.inalpha-web.pages.dev
Branch Preview URL: https://codex-trial-activation-email.inalpha-web.pages.dev

View logs

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Reviewed PR head: 33c6f5df7e02

🤖 DeepSeek Code Review

Adds SMTP-based trial activation emails: on admin approval (approve decision) the dashboard BFF sends a one-time activation link to the applicant, surfaces sent/failed status in the UI, and exposes the applicant email from the Paper review endpoint; SMTP credentials are injected into the dashboard container.

Critical Major Medium
0 1 2

Findings

1. [MAJOR] SMTP credentials injected into public-facing dashboard container reverses minimal-privilege boundary

Location: infra/docker-compose.prod.yml:244

  • Evidence: The pre-existing comment in this service explicitly states the dashboard is a public frontend and deliberately does NOT mount env_file to avoid injecting DB/Redis/LLM/tunnel credentials, keeping only JWT_SECRET + internal URLs: 'RCE 即全泄'. The new block adds SMTP_HOST/PORT/USER/PASSWORD into `environment:` of that same container. The comment is edited to justify it, but the boundary is still removed: the SMTP credential now lives in the most exposed service.
  • Impact: Any RCE/SSRF/deserialization in the Next.js BFF now leaks the org's SMTP app credential, letting an attacker send arbitrary outbound mail (phishing from the real sender address, sender-reputation and domain-trust damage) — exactly the blast radius the original design tried to prevent.
  • Suggested fix: Send the email from an internal, non-public service (Paper already owns the token + applicant email at review time) or a dedicated internal mailer, and keep the dashboard free of SMTP secrets. If the dashboard must send, use a narrowly scoped credential and document the accepted risk explicitly.

2. [MEDIUM] Approval request blocks on synchronous SMTP send (up to 15s)

Location: apps/dashboard/src/app/api/admin/waitlist/[subject]/review/route.ts:50

  • Evidence: `const email_delivery = decision === "approve" && result.activation_token ? await sendActivationEmail(...) : undefined;` runs inline before returning. sendActivationEmail races sendMail against a 15_000ms deadline plus connection/greeting timeouts. When the SMTP host is unreachable or slow, the admin's approve click is held for the full timeout.
  • Impact: Admin UI appears to hang for up to 15s per approval during any SMTP degradation; with several queued approvals this compounds. The approval is already committed server-side, so the delayed response adds no safety, only latency.
  • Suggested fix: Decouple sending from the request (fire-and-forget/queue and expose status separately), or lower the deadline substantially (e.g. 3–5s) and show an optimistic 'sending' state so the admin is not blocked on network I/O.

3. [MEDIUM] Activation email hardcodes bilingual CN+EN content, ignoring applicant locale

Location: apps/dashboard/src/lib/activation-mail.ts:34

  • Evidence: Subject is `"Inalpha 试用申请已通过 / Your trial is approved"` and the body is a fixed Chinese+English string. Every recipient, regardless of language, receives both languages. Project hard constraint: '面向全球用户:不预设语言... prompt 写死中英文 = bug'. UI strings were properly localized in messages/en.json + zh.json, but the email bypasses this.
  • Impact: Global applicants get a jarring Chinese-first bilingual email, contradicting the product's no-preset-language rule; non-CN/EN speakers may not understand the link instructions, hurting activation conversion.
  • Suggested fix: Persist/derive the applicant's locale at registration and select localized subject/body from the same i18n resource used by the dashboard, falling back only when locale is unknown.
Review scope and limitations

Reviewed the supplied diff and project rules. No tests were executed by this reviewer.

  • @types/nodemailer@^8.0.2 is installed against nodemailer@10.5.0 (major-version mismatch); whether the DefinitelyTyped types match the runtime API (and pass typecheck) is unverified.
  • README claims email is also sent on 'regenerate activation link', but only the review route is in the diff; the regenerate path (and whether it reuses decision=approve) cannot be confirmed.
  • No test exercises the route branch returning email_delivery='not_configured', or the UI rendering it as failure; SMTP-credential exposure scenario has no automated coverage.
  • Tests are present but no test run is claimed in the review; CI (pnpm typecheck/vitest, ruff, pytest) status unknown.

@mirror29
mirror29 merged commit 80aaf6c into main Nov 16, 2026
16 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