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

Closed
opened 2026-03-13 12:54:57 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5922
Author: @bytaesu
Created: 11/12/2025
Status: Merged
Merged: 11/12/2025
Merged by: @Bekacru

Base: canaryHead: 2025-11-12/feat/anon-plugin-email


📝 Commits (5)

  • 28f8076 refactor: adjust file structure
  • 9d481da feat: generateRandomEmail option
  • b4f4adb test: update email related test cases
  • 3849257 docs: update anon plugin content
  • 7f90ce5 test: proper getTestInstance usage

📊 Changes

6 files changed (+329 additions, -149 deletions)

View changed files

📝 docs/content/docs/plugins/anonymous.mdx (+39 -5)
📝 packages/better-auth/src/plugins/anonymous/anon.test.ts (+173 -56)
packages/better-auth/src/plugins/anonymous/error-codes.ts (+9 -0)
📝 packages/better-auth/src/plugins/anonymous/index.ts (+30 -88)
packages/better-auth/src/plugins/anonymous/schema.ts (+13 -0)
packages/better-auth/src/plugins/anonymous/types.ts (+65 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5922 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 11/12/2025 **Status:** ✅ Merged **Merged:** 11/12/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `2025-11-12/feat/anon-plugin-email` --- ### 📝 Commits (5) - [`28f8076`](https://github.com/better-auth/better-auth/commit/28f8076629669303ff96d6e30453415d007ceb67) refactor: adjust file structure - [`9d481da`](https://github.com/better-auth/better-auth/commit/9d481da4ec11201c6c05fbf745ff6a2414000f17) feat: generateRandomEmail option - [`b4f4adb`](https://github.com/better-auth/better-auth/commit/b4f4adb17e2138a19a2b236a4635ae4f68d67b4e) test: update email related test cases - [`3849257`](https://github.com/better-auth/better-auth/commit/3849257cdf10bf8ecb172f44c54bdeb2f1645ccb) docs: update anon plugin content - [`7f90ce5`](https://github.com/better-auth/better-auth/commit/7f90ce56097e7954e9e87cb6d417b94198d3ac42) test: proper getTestInstance usage ### 📊 Changes **6 files changed** (+329 additions, -149 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/anonymous.mdx` (+39 -5) 📝 `packages/better-auth/src/plugins/anonymous/anon.test.ts` (+173 -56) ➕ `packages/better-auth/src/plugins/anonymous/error-codes.ts` (+9 -0) 📝 `packages/better-auth/src/plugins/anonymous/index.ts` (+30 -88) ➕ `packages/better-auth/src/plugins/anonymous/schema.ts` (+13 -0) ➕ `packages/better-auth/src/plugins/anonymous/types.ts` (+65 -0) </details> ### 📄 Description 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. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:54:57 -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#6325