[PR #2660] [CLOSED] feat: add sendVerificationOnSignIn to prevent automatic resending of verification email on login with requireEmailVerification #21330

Closed
opened 2026-04-15 20:17:29 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/2660
Author: @jingerpie
Created: 5/14/2025
Status: Closed

Base: mainHead: main


📝 Commits (1)

  • b391c5e feat: add sendVerificationOnSignIn

📊 Changes

7 files changed (+145 additions, -34 deletions)

View changed files

📝 docs/content/docs/authentication/email-password.mdx (+54 -15)
📝 docs/content/docs/concepts/email.mdx (+24 -1)
📝 docs/content/docs/reference/options.mdx (+2 -0)
📝 packages/better-auth/src/api/routes/email-verification.test.ts (+30 -0)
📝 packages/better-auth/src/api/routes/sign-in.ts (+22 -17)
📝 packages/better-auth/src/plugins/username/index.ts (+4 -1)
📝 packages/better-auth/src/types/options.ts (+9 -0)

📄 Description

This pull request introduces a new configuration option, sendVerificationOnSignIn, to provide more control over email verification during the sign-in process. The changes span documentation updates, backend logic, and test cases to support this feature. Key updates include the ability to disable automatic verification emails and manually trigger them, alongside enhanced flexibility for developers in customizing the user authentication flow.

Documentation Updates:

  • Added explanations and examples for the new sendVerificationOnSignIn option in the authentication documentation (docs/content/docs/authentication/email-password.mdx, docs/content/docs/concepts/email.mdx, docs/content/docs/reference/options.mdx). [1] [2] [3] [4] [5]

Backend Logic Enhancements:

  • Updated the sign-in endpoint to respect the sendVerificationOnSignIn option, skipping automatic email verification when set to false (packages/better-auth/src/api/routes/sign-in.ts). [1] [2]
  • Added similar logic to the username plugin to conditionally send verification emails based on the new option (packages/better-auth/src/plugins/username/index.ts).

Type Definitions:

  • Introduced the sendVerificationOnSignIn property in the BetterAuthOptions type, with a default value of true (packages/better-auth/src/types/options.ts).

Test Coverage:

  • Added a test case to ensure no verification email is sent when sendVerificationOnSignIn is set to false (packages/better-auth/src/api/routes/email-verification.test.ts).

🔄 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/2660 **Author:** [@jingerpie](https://github.com/jingerpie) **Created:** 5/14/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`b391c5e`](https://github.com/better-auth/better-auth/commit/b391c5e12ec0b868e103305c3ea489e2ee297855) feat: add sendVerificationOnSignIn ### 📊 Changes **7 files changed** (+145 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/authentication/email-password.mdx` (+54 -15) 📝 `docs/content/docs/concepts/email.mdx` (+24 -1) 📝 `docs/content/docs/reference/options.mdx` (+2 -0) 📝 `packages/better-auth/src/api/routes/email-verification.test.ts` (+30 -0) 📝 `packages/better-auth/src/api/routes/sign-in.ts` (+22 -17) 📝 `packages/better-auth/src/plugins/username/index.ts` (+4 -1) 📝 `packages/better-auth/src/types/options.ts` (+9 -0) </details> ### 📄 Description This pull request introduces a new configuration option, `sendVerificationOnSignIn`, to provide more control over email verification during the sign-in process. The changes span documentation updates, backend logic, and test cases to support this feature. Key updates include the ability to disable automatic verification emails and manually trigger them, alongside enhanced flexibility for developers in customizing the user authentication flow. ### Documentation Updates: * Added explanations and examples for the new `sendVerificationOnSignIn` option in the authentication documentation (`docs/content/docs/authentication/email-password.mdx`, `docs/content/docs/concepts/email.mdx`, `docs/content/docs/reference/options.mdx`). [[1]](diffhunk://#diff-dae429fa3662f75a0374f14e5c0564fd7b3e14aedbce267b4f5537cd97db5e78L137-R186) [[2]](diffhunk://#diff-dae429fa3662f75a0374f14e5c0564fd7b3e14aedbce267b4f5537cd97db5e78R310-R319) [[3]](diffhunk://#diff-100613a5a97d8e43008d0d33731d4bfdf97f74435e5b3478f773a5d17eaa5c05R81-R103) [[4]](diffhunk://#diff-31827aa0dc7160b3102b6a05cd14641760cd34bf5ff499a40d16862b36345819R138) [[5]](diffhunk://#diff-31827aa0dc7160b3102b6a05cd14641760cd34bf5ff499a40d16862b36345819R163) ### Backend Logic Enhancements: * Updated the `sign-in` endpoint to respect the `sendVerificationOnSignIn` option, skipping automatic email verification when set to `false` (`packages/better-auth/src/api/routes/sign-in.ts`). [[1]](diffhunk://#diff-d23d71b9544f44d17b8e26b0a1ed49fc5fc804aaa290db92dbfb5665c7df4797R504-R506) [[2]](diffhunk://#diff-d23d71b9544f44d17b8e26b0a1ed49fc5fc804aaa290db92dbfb5665c7df4797R524-R525) * Added similar logic to the `username` plugin to conditionally send verification emails based on the new option (`packages/better-auth/src/plugins/username/index.ts`). ### Type Definitions: * Introduced the `sendVerificationOnSignIn` property in the `BetterAuthOptions` type, with a default value of `true` (`packages/better-auth/src/types/options.ts`). ### Test Coverage: * Added a test case to ensure no verification email is sent when `sendVerificationOnSignIn` is set to `false` (`packages/better-auth/src/api/routes/email-verification.test.ts`). --- <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-04-15 20:17:29 -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#21330