[PR #3293] [CLOSED] feat(email-verification): make verification email send on unverified account sign-in optional #4740

Closed
opened 2026-03-13 11:58:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3293
Author: @LightTab2
Created: 7/7/2025
Status: Closed

Base: v1.3Head: feat/sendVerificationOnSignIn


📝 Commits (8)

📊 Changes

7 files changed (+144 additions, -3 deletions)

View changed files

📝 docs/content/docs/authentication/email-password.mdx (+56 -0)
📝 docs/content/docs/concepts/email.mdx (+18 -1)
📝 docs/content/docs/reference/options.mdx (+2 -0)
📝 packages/better-auth/src/api/routes/email-verification.test.ts (+48 -0)
📝 packages/better-auth/src/api/routes/sign-in.ts (+4 -1)
📝 packages/better-auth/src/plugins/username/index.ts (+7 -1)
📝 packages/better-auth/src/types/options.ts (+9 -0)

📄 Description

I have tidied up and fixed tests of #2660 by @JingerTea
Great work!

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).

_Originally posted by @JingerTea in https://github.com/better-auth/better-auth/issues/2660

Resolves #2447
Resolves #2660


🔄 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/3293 **Author:** [@LightTab2](https://github.com/LightTab2) **Created:** 7/7/2025 **Status:** ❌ Closed **Base:** `v1.3` ← **Head:** `feat/sendVerificationOnSignIn` --- ### 📝 Commits (8) - [`b391c5e`](https://github.com/better-auth/better-auth/commit/b391c5e12ec0b868e103305c3ea489e2ee297855) feat: add sendVerificationOnSignIn - [`45df2cc`](https://github.com/better-auth/better-auth/commit/45df2cc8ee296334af33a125cdcc956edb3923d1) Merge branch 'main' of https://github.com/JingerTea/better-auth into JingerTea-main - [`04ca461`](https://github.com/better-auth/better-auth/commit/04ca4618396d1dd4c79783fa4b55d34179dcd6c1) Merge branch 'JingerTea-main' into feat/sendVerificationOnSignIn - [`839a714`](https://github.com/better-auth/better-auth/commit/839a7142bac7691dad364d1af6aee069352cec77) Simplifies documentation - [`62ec06f`](https://github.com/better-auth/better-auth/commit/62ec06fa41111747c7422bcc4e4fd1b7ff3a573e) Fixes test - [`6ef5bc3`](https://github.com/better-auth/better-auth/commit/6ef5bc33544a3f878969124d493affa0002010da) Lint - [`2ed9612`](https://github.com/better-auth/better-auth/commit/2ed9612728d85e159f09cfb42d80c9a744f9da5c) Fix by AI - [`caedcd0`](https://github.com/better-auth/better-auth/commit/caedcd028aa99b60d71d3db07ba00cf8d83b866d) Merge branch 'v1.3' into feat/sendVerificationOnSignIn ### 📊 Changes **7 files changed** (+144 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/authentication/email-password.mdx` (+56 -0) 📝 `docs/content/docs/concepts/email.mdx` (+18 -1) 📝 `docs/content/docs/reference/options.mdx` (+2 -0) 📝 `packages/better-auth/src/api/routes/email-verification.test.ts` (+48 -0) 📝 `packages/better-auth/src/api/routes/sign-in.ts` (+4 -1) 📝 `packages/better-auth/src/plugins/username/index.ts` (+7 -1) 📝 `packages/better-auth/src/types/options.ts` (+9 -0) </details> ### 📄 Description I have tidied up and fixed tests of #2660 by @JingerTea Great work! > 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]](https://github.com/better-auth/better-auth/pull/2660/files#diff-dae429fa3662f75a0374f14e5c0564fd7b3e14aedbce267b4f5537cd97db5e78L137-R186) [[2]](https://github.com/better-auth/better-auth/pull/2660/files#diff-dae429fa3662f75a0374f14e5c0564fd7b3e14aedbce267b4f5537cd97db5e78R310-R319) [[3]](https://github.com/better-auth/better-auth/pull/2660/files#diff-100613a5a97d8e43008d0d33731d4bfdf97f74435e5b3478f773a5d17eaa5c05R81-R103) [[4]](https://github.com/better-auth/better-auth/pull/2660/files#diff-31827aa0dc7160b3102b6a05cd14641760cd34bf5ff499a40d16862b36345819R138) [[5]](https://github.com/better-auth/better-auth/pull/2660/files#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]](https://github.com/better-auth/better-auth/pull/2660/files#diff-d23d71b9544f44d17b8e26b0a1ed49fc5fc804aaa290db92dbfb5665c7df4797R504-R506) [[2]](https://github.com/better-auth/better-auth/pull/2660/files#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`). _Originally posted by @JingerTea in https://github.com/better-auth/better-auth/issues/2660 Resolves #2447 Resolves #2660 --- <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 11:58:13 -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#4740