[PR #5901] [CLOSED] feat(anonymous): more flexible temporary email generation #6307

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5901
Author: @bytaesu
Created: 11/11/2025
Status: Closed

Base: canaryHead: 2025-11-11/feat/flexible-anonymous-email


📝 Commits (2)

  • b904cfe feat: more flexible anonymous email and some refactoring
  • d2e9b1a docs: update anon plugin content

📊 Changes

6 files changed (+156 additions, -91 deletions)

View changed files

📝 docs/content/docs/plugins/anonymous.mdx (+24 -2)
packages/better-auth/src/plugins/anonymous/error-codes.ts (+8 -0)
📝 packages/better-auth/src/plugins/anonymous/index.ts (+34 -89)
packages/better-auth/src/plugins/anonymous/schema.ts (+13 -0)
packages/better-auth/src/plugins/anonymous/types.ts (+65 -0)
packages/better-auth/src/plugins/anonymous/utils.ts (+12 -0)

📄 Description

This PR includes the following changes:

  • Fixed issue where emails could be created with invalid domain names
  • Added local part option for more flexible email generation
  • Added validation for invalid emails during initialization
  • Refactored anon plugin file structure
  • Updated related documentation

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


Summary by cubic

Makes temporary email generation for anonymous users more flexible and safe. Adds options for local part and domain, and validates generated emails to prevent invalid addresses.

  • New Features

    • Added emailLocalPart and emailDomainName options for temporary emails.
    • Validates generated emails on init; throws a clear BetterAuthError if invalid.
    • Introduced centralized error codes and extracted schema/types/utils.
    • Fixed invalid domain name creation and updated docs.
  • Migration

    • Default behavior changed: if no domain is provided, emails use {localPart}@{id}.com (previously used the site domain). Set emailDomainName (and optionally emailLocalPart) if you rely on a specific domain.
    • Custom email settings must produce a valid address; invalid configs will fail at startup.

Written for commit d2e9b1ac17. 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/5901 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 11/11/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `2025-11-11/feat/flexible-anonymous-email` --- ### 📝 Commits (2) - [`b904cfe`](https://github.com/better-auth/better-auth/commit/b904cfe19c6a4199c14cf2415ef1d204e617f849) feat: more flexible anonymous email and some refactoring - [`d2e9b1a`](https://github.com/better-auth/better-auth/commit/d2e9b1ac177e7730b055a065f8c2f0319a5c8816) docs: update anon plugin content ### 📊 Changes **6 files changed** (+156 additions, -91 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/anonymous.mdx` (+24 -2) ➕ `packages/better-auth/src/plugins/anonymous/error-codes.ts` (+8 -0) 📝 `packages/better-auth/src/plugins/anonymous/index.ts` (+34 -89) ➕ `packages/better-auth/src/plugins/anonymous/schema.ts` (+13 -0) ➕ `packages/better-auth/src/plugins/anonymous/types.ts` (+65 -0) ➕ `packages/better-auth/src/plugins/anonymous/utils.ts` (+12 -0) </details> ### 📄 Description This PR includes the following changes: - Fixed issue where emails could be created with invalid domain names - Added local part option for more flexible email generation - Added validation for invalid emails during initialization - Refactored anon plugin file structure - Updated related documentation Related https://github.com/better-auth/better-auth/issues/4913 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Makes temporary email generation for anonymous users more flexible and safe. Adds options for local part and domain, and validates generated emails to prevent invalid addresses. - **New Features** - Added emailLocalPart and emailDomainName options for temporary emails. - Validates generated emails on init; throws a clear BetterAuthError if invalid. - Introduced centralized error codes and extracted schema/types/utils. - Fixed invalid domain name creation and updated docs. - **Migration** - Default behavior changed: if no domain is provided, emails use `{localPart}@{id}.com` (previously used the site domain). Set emailDomainName (and optionally emailLocalPart) if you rely on a specific domain. - Custom email settings must produce a valid address; invalid configs will fail at startup. <sup>Written for commit d2e9b1ac177e7730b055a065f8c2f0319a5c8816. 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:15 -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#6307