Skip to content

feat(users): host-overridable auth email templates with an HTML part (#712) - #716

Merged
antosubash merged 3 commits into
mainfrom
feat/b30-users-mail-templates
Oct 30, 2026
Merged

antosubash merged 3 commits into
mainfrom
feat/b30-users-mail-templates

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Hosts can now override the users module's auth emails and send them with an HTML part.

Closes #712

What changed

  • New DB setting UsersSettings.mail_template_dirs (a list of absolute directories, restart-required, no env var). The mailer searches them in order, then the bundled templates, for each file separately, so a host can override just one email.
  • Optional .html siblings (verify_email.html, reset_password.html, invite.html) are rendered with autoescape on and sent as MailMessage.html next to the text part. Without one, the email is text-only, as before.
  • Templates render in Jinja's sandbox. The directory list can be edited from the admin settings UI, so a template file dropped into a writable directory must not be able to run Python. This was raised by review and by the automated security check; a test proves the classic __class__.__mro__ escape is refused.
  • A bad directory never stops the app booting. Relative, missing or non-directory entries are skipped with a warning.
  • Each mailer owns its Jinja environment (the module-global one is gone), so two apps in one process can't share overrides.
  • TemplatedMailer and build_mailer take a keyword-only template_dirs= argument.
  • Docs: docs/modules/users.md § Overriding auth email templates, plus the settings table.

Verification

  • make lint ✓ · make test-js ✓ · make test-py ✓ (6472 passed, 41 skipped)
  • test_users_mailer_templates.py (16 tests): directory order, per-file fallback, HTML-only override, escaping, sandbox, invalid dirs skipped, startup forwarding the DB setting.
  • Code review: two reviewers. They fixed the sandbox, a stale docstring, the docs and the settings row; four further findings were rejected with reasons recorded.
  • No browser QA: no UI change.

https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4b6c26f
Status: ✅  Deploy successful!
Preview URL: https://2bb77d37.simple-module-python.pages.dev
Branch Preview URL: https://feat-b30-users-mail-template.simple-module-python.pages.dev

View logs

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-10-30T21:35:09.359878Z 4b6c26f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@antosubash
antosubash merged commit 07ebd3f into main Oct 30, 2026
17 checks passed
@antosubash
antosubash deleted the feat/b30-users-mail-templates branch October 30, 2026 21:41
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.

users: host-overridable auth email templates with an HTML part

1 participant