Repository navigation
feat(studio): restrict auth email template editing for free projects - #45396
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
6 Skipped Deployments
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughDetects whether a custom email sender is configured, gates email template editing with a read-only TemplateEditor prop when not configured, adds SMTP disable confirmation and template-reset flows, and updates email/template copy and example subjects across docs and templates. ChangesEmail Template Editing Restrictions and Management
Sequence DiagramsequenceDiagram
participant Page as Template Detail Page
participant Utils as Restriction Utils
participant AuthConfig as Auth Config
participant Editor as TemplateEditor
participant UI as Editor UI
Page->>Utils: hasCustomEmailSender(authConfig)
Utils->>AuthConfig: inspect SMTP_* and HOOK_SEND_EMAIL_*
AuthConfig-->>Utils: hasCustomSender (true/false)
Utils-->>Page: editingRestricted / statusKnown
Page->>Editor: pass isReadOnly
Editor->>Editor: canEdit = canUpdateConfig && !isReadOnly
Editor->>UI: disable fields / CodeEditor readOnly when !canEdit
Editor->>UI: force preview view when canEdit becomes false
UI-->>Page: read-only editor rendered
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
🎭 Playwright Test ResultsDetails
Flaky testsFeatures › assistant.spec.ts › AI Assistant › Can send a message to the assistant and receive a response Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
31db1dd to
d245db9
Compare
…com/supabase/supabase into dnywh/auth-email-health-lightweight
joshenlim
left a comment
There was a problem hiding this comment.
Am approving to unblock - have also tested locally against the related infra branch
- Disabling custom SMTP on free project resets all email templates
- Projects before cutoff date still have editing access
- Projects after cutoff date do not have editing access
Let me know if I might have missed anything to test, but we'll probably want to do one more round of testing if the infra PR had any changes
joshenlim
left a comment
There was a problem hiding this comment.
Just doing one last check given that the platform PR has been merged
Tested locally against the platform branch
- Unable to edit templates if projects are created past the cutoff date
- Disabling custom SMTP resets the templates
Let me know if there's anything i overlooked!
Just one thing we need to confirm before merging this though as we're showing this confirmation dialog when disabling custom SMTP

I'm assuming this isn't true RE resetting templates until the platform changes are deployed? If so, then either we add a feature flag or we wait till platform changes are through before merging this one.
|
@joshenlim this will be pretty impossible to test against staging because of the cutoff date. Edit: maybe it would be a good idea to have a feature flag (killswitch) for this like we do platform? |
This comment has been minimized.
This comment has been minimized.
Braintrust eval reportAssistant (bt::sp::custom::GitHub Actions-e1f8e343-7ee3-4763-ae7f-62d4550a6e7c-1779945933)
|
… dialog (#46319) ## What kind of change does this PR introduce? Feature. Implements [AUTH-1215](https://linear.app/supabase/issue/AUTH-1215/improve-studio-ui-when-send-email-hook-is-active-or-deleted). Follow-up to #45396. ## What is the current behavior? When a send-email hook is configured, email templates are bypassed entirely. Auth passes event metadata to the hook, not rendered HTML. The template list and editor give no indication of this. Deleting the send-email hook silently reverts Auth to using email templates with no warning. For post-cutoff Free plan projects without custom SMTP, this also locks template editing. ## What is the new behavior? ### Admonition when send-email hook is active A new `SendEmailHookActiveAdmonition` is shown on both the template list and individual template editor pages when `HOOK_SEND_EMAIL_ENABLED` and `HOOK_SEND_EMAIL_URI` are set: > **Email templates are not used** > A Send Email hook is active. Event metadata is passed directly to your hook, meaning these templates are bypassed entirely. With a **Manage hook** link to the hooks page. ### AlertDialog for Send Email hook deletion Deleting the Send Email hook now uses a dedicated `DeleteSendEmailHookConfirmationDialog`: - **Always:** "The {default or built-in} email templates will be used to send auth emails." - **Post-cutoff Free plan, no custom SMTP:** adds "Email templates cannot be edited on the Free plan without custom SMTP." The dialog stays open with a loading state while the deletion is in-flight and closes on success. | After | | --- | | <img width="1862" height="880" alt="CleanShot 2026-05-25 at 15 57 41@2x" src="https://github.com/user-attachments/assets/8a441bb2-9112-4b19-bd0b-02c9d1989ec1" /> | | <img width="884" height="578" alt="CleanShot 2026-05-25 at 15 57 21@2x" src="https://github.com/user-attachments/assets/44e5bd79-2bd9-44ee-8f53-5fdaeefd68c6" /> | <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a Send Email hook warning in the template editor with “Manage hook” and “Learn more” links. * **UI Improvements** * Refined template editor alerts to reflect when templates are bypassed vs blocked. * Updated hook cards/actions to a dropdown with separate Edit and Delete flows, including documentation links. * **Bug Fixes** * Improved template editor and hook deletion flows to better reflect pending states and current authentication configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Joshen Lim <[email protected]> Co-authored-by: Claude Sonnet 4.5 <[email protected]> Co-authored-by: Cursor <[email protected]>
What kind of change does this PR introduce?
Feature / abuse-prevention update. Resolves DEPR-198.
What is the current behaviour?
Free projects using Supabase's built-in email service can edit raw Auth email template subjects and HTML in Studio. That is the risky cohort this project is trying to constrain.
What is the new behaviour?
Template editing restrictions
For free projects using Supabase's built-in email service, Studio keeps Auth email templates viewable and previewable but disables subject/body editing and saving. Editing is unlocked by setting up Custom SMTP, configuring a send-email hook, or upgrading to a paid plan.
Grandfathering: projects created before
2026-06-01T00:00:00Z(the platform enforcement cutoff) are exempt; their editing UI stays unlocked. This mirrorsFREE_TIER_TEMPLATE_BLOCK_CUTOFF_DATEin the platform PR exactly.Warning dialogs on transitions that reset templates
Two flows now surface a warning before the user commits to a state change that resets their custom email templates to defaults:
Disabling custom SMTP (SMTP settings page): a confirmation dialog warns that templates will be reset to defaults and the email rate limit reduced to 2 per hour. On confirm, Studio resets all 13 templates via the existing per-template reset endpoint (
Promise.allSettled). The "won't be able to edit" sentence is shown only for post-cutoff projects; grandfathered projects skip it. The corresponding server-side enforcement is in the Platform PR: https://github.com/supabase/platform/pull/33129Downgrading to the Free plan (billing settings): an admonition in the existing downgrade confirmation modal warns that custom templates will be reset to defaults and won't be editable without custom SMTP. The admonition is shown only when the org has at least one post-cutoff project; orgs whose projects are all grandfathered skip it.
Informational admonition when enabling SMTP
When a user enables custom SMTP for the first time, a sandwiched admonition above the save footer informs them that the email rate limit will be increased to 30 per hour and can be adjusted.
This is just a minor cosmetic change, unrelated to the email template disabling. Sorry.
How to test
All existing projects pre-date the enforcement cutoff (
2026-06-01T00:00:00Z) and are grandfathered, so the restriction UI won't appear by default. To force the restricted state locally, back-date the cutoff in one file:In
apps/studio/components/interfaces/Auth/EmailTemplates/EmailTemplates.utils.ts, temporarily change:to:
Revert before committing. With the cutoff back-dated, use a free-plan project and:
Additional context
The default Auth email template copy was also improved across docs, examples, and UI library snippets (separate prior commits).
The per-template reset button (
ResetTemplateDialog) was migrated to the asyncAlertDialogActionpattern introduced in #45960; the dialog stays open and shows a loading state while the reset is in-flight, closes on success, and stays open on error.Closes PRODSEC-183