[PR #4835] [MERGED] fix(better-auth): moved email verification check after password check #5604

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4835
Author: @QuintenStr
Created: 9/23/2025
Status: Merged
Merged: 9/25/2025
Merged by: @himself65

Base: canaryHead: fix/email-verification-after-password


📝 Commits (4)

  • 09684d3 fix: moved email verification check after password check
  • 8c85bd8 Merge branch 'better-auth:canary' into fix/email-verification-after-password
  • 3579cc0 test: email verification check after password
  • c3e3bc0 Merge branch 'fix/email-verification-after-password' of https://github.com/QuintenStr/better-auth into fix/email-verification-after-password

📊 Changes

2 files changed (+79 additions, -37 deletions)

View changed files

📝 packages/better-auth/src/plugins/username/index.ts (+38 -37)
📝 packages/better-auth/src/plugins/username/username.test.ts (+41 -0)

📄 Description

Clearly describe what changes you made and why

I moved the email verification check to after the password validation check. The issue was that on username sign in, nonetheless if the password was correct, you'd always get email verification error (if the user's email is unverified). This leaks information of the user, and is a possible spam vulnerability for email sending.

Include any relevant context or background

Just moved the same code a bit lower. Refer to changed file.

List any breaking changes or deprecations

No breaking changes found. All username plugin tests still run.

Add screenshots for UI changes

No UI changes.

Not applicable.


Summary by cubic

Moved the email verification check to run after password validation in the username sign-in flow. This prevents leaking unverified status on incorrect passwords and avoids sending verification emails unless the password is correct.

  • Bug Fixes
    • Validate password first; skip email verification when password is wrong.
    • Check email verification only after a valid password and block sign-in if unverified.
    • Send verification email on sign-in (if enabled) only after password is confirmed.

🔄 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/4835 **Author:** [@QuintenStr](https://github.com/QuintenStr) **Created:** 9/23/2025 **Status:** ✅ Merged **Merged:** 9/25/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/email-verification-after-password` --- ### 📝 Commits (4) - [`09684d3`](https://github.com/better-auth/better-auth/commit/09684d35d6085c4b20a227ebf245d4a129930165) fix: moved email verification check after password check - [`8c85bd8`](https://github.com/better-auth/better-auth/commit/8c85bd819c9dfef5c33a50421232c9a5f4764574) Merge branch 'better-auth:canary' into fix/email-verification-after-password - [`3579cc0`](https://github.com/better-auth/better-auth/commit/3579cc09d5da5371848823c70a22034ef1d6f0fa) test: email verification check after password - [`c3e3bc0`](https://github.com/better-auth/better-auth/commit/c3e3bc0f8563de5d47e080fecf3dbe51f307966d) Merge branch 'fix/email-verification-after-password' of https://github.com/QuintenStr/better-auth into fix/email-verification-after-password ### 📊 Changes **2 files changed** (+79 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/username/index.ts` (+38 -37) 📝 `packages/better-auth/src/plugins/username/username.test.ts` (+41 -0) </details> ### 📄 Description ### Clearly describe what changes you made and why I moved the email verification check to after the password validation check. The issue was that on username sign in, nonetheless if the password was correct, you'd always get email verification error (if the user's email is unverified). This leaks information of the user, and is a possible spam vulnerability for email sending. ### Include any relevant context or background Just moved the same code a bit lower. Refer to changed file. ### List any breaking changes or deprecations No breaking changes found. All username plugin tests still run. ### Add screenshots for UI changes No UI changes. ### Reference related issues or discussions Not applicable. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Moved the email verification check to run after password validation in the username sign-in flow. This prevents leaking unverified status on incorrect passwords and avoids sending verification emails unless the password is correct. - **Bug Fixes** - Validate password first; skip email verification when password is wrong. - Check email verification only after a valid password and block sign-in if unverified. - Send verification email on sign-in (if enabled) only after password is confirmed. <!-- 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:29:11 -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#5604