[PR #7215] [MERGED] fix(email-verification): sending email verification of another user fails with EMAIL_ALREADY_VERIFIED #15398

Closed
opened 2026-04-13 10:00:54 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7215
Author: @ping-maxwell
Created: 1/9/2026
Status: Merged
Merged: 1/9/2026
Merged by: @Bekacru

Base: canaryHead: fix/email-verification/sending-email-verification-of-another-user-will-fail-with-EMAIL_ALREADY_VERIFIED


📝 Commits (1)

  • f31d77a fix(email-verification): sending email verification of another user will fail with EMAIL_ALREADY_VERIFIED

📊 Changes

1 file changed (+3 additions, -3 deletions)

View changed files

📝 packages/better-auth/src/api/routes/email-verification.ts (+3 -3)

📄 Description

Closes https://github.com/better-auth/better-auth/issues/5621

The /send-verification-email endpoint is meant to be called by the user who intends to verify the email, not someone else - such as an admin.

If you didn't know this and ran through this flow, you'll meet an unexpected error: "Email already verified" - even if the user was just created using the admin plugin.

This error stems from the admin user info being email verified, not the actual new user. Our if-statement logic to ensure that the session is equal to the email that is trying to be verified is performed later down the line from the email_already_verified error, and thus creates confusion.

This PR simply moves that if-statement earlier for devs to correctly understand the issue and that they can't call that endpoint for users.


Summary by cubic

Reordered validation in the /send-verification-email endpoint to check for email mismatch before emailVerified. This fixes confusing EMAIL_ALREADY_VERIFIED errors when an admin tries to verify another user; the endpoint now returns EMAIL_MISMATCH and enforces that users can only verify their own email.

Written for commit f31d77ae2c. Summary will update 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/7215 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 1/9/2026 **Status:** ✅ Merged **Merged:** 1/9/2026 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/email-verification/sending-email-verification-of-another-user-will-fail-with-EMAIL_ALREADY_VERIFIED` --- ### 📝 Commits (1) - [`f31d77a`](https://github.com/better-auth/better-auth/commit/f31d77ae2c74bd9480f3f111b0bfdb1bfef1b7c6) fix(email-verification): sending email verification of another user will fail with EMAIL_ALREADY_VERIFIED ### 📊 Changes **1 file changed** (+3 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/email-verification.ts` (+3 -3) </details> ### 📄 Description Closes https://github.com/better-auth/better-auth/issues/5621 The `/send-verification-email` endpoint is meant to be called by the user who intends to verify the email, not someone else - such as an admin. If you didn't know this and ran through this flow, you'll meet an unexpected error: "Email already verified" - even if the user was just created using the admin plugin. This error stems from the admin user info being email verified, not the actual new user. Our if-statement logic to ensure that the session is equal to the email that is trying to be verified is performed later down the line from the email_already_verified error, and thus creates confusion. This PR simply moves that if-statement earlier for devs to correctly understand the issue and that they can't call that endpoint for users. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Reordered validation in the /send-verification-email endpoint to check for email mismatch before emailVerified. This fixes confusing EMAIL_ALREADY_VERIFIED errors when an admin tries to verify another user; the endpoint now returns EMAIL_MISMATCH and enforces that users can only verify their own email. <sup>Written for commit f31d77ae2c74bd9480f3f111b0bfdb1bfef1b7c6. Summary will update 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-04-13 10:00:54 -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#15398