[PR #5922] feat(anonymous): allow customizing random email generator #14572

Closed
opened 2026-04-13 09:31:55 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5922

State: closed
Merged: Yes


This PR includes the following changes:

  • Refactor anon plugin file structure
  • Change default email format to fix emails containing the protocol
  • Add generateRandomEmail option to use a custom email generation function
  • Update related documentation

Related https://github.com/better-auth/better-auth/issues/4913


Summary by cubic

Update the anonymous plugin to fix invalid default emails and add a custom email generator. Default emails are now temp@{id}.com, and you can use generateRandomEmail to define your own format.

  • New Features

    • Added generateRandomEmail option (sync or async). Returns an error if the email is invalid.
    • Updated defaults: temp@{id}.com by default; with emailDomainName, emails are temp-{id}@.
  • Migration

    • If you relied on baseURL-derived emails, set emailDomainName (e.g., "example.com") to keep that pattern.
    • When using generateRandomEmail, ensure it returns a unique, valid email; emailDomainName is ignored.

Written for commit 7f90ce5609. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5922 **State:** closed **Merged:** Yes --- This PR includes the following changes: - Refactor anon plugin file structure - Change default email format to fix emails containing the protocol - Add `generateRandomEmail ` option to use a custom email generation function - Update related documentation Related https://github.com/better-auth/better-auth/issues/4913 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Update the anonymous plugin to fix invalid default emails and add a custom email generator. Default emails are now temp@{id}.com, and you can use generateRandomEmail to define your own format. - **New Features** - Added generateRandomEmail option (sync or async). Returns an error if the email is invalid. - Updated defaults: temp@{id}.com by default; with emailDomainName, emails are temp-{id}@<domain>. - **Migration** - If you relied on baseURL-derived emails, set emailDomainName (e.g., "example.com") to keep that pattern. - When using generateRandomEmail, ensure it returns a unique, valid email; emailDomainName is ignored. <sup>Written for commit 7f90ce56097e7954e9e87cb6d417b94198d3ac42. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:31:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14572