[PR #7198] [CLOSED] fix: finalize email changes only after successful verification #7137

Closed
opened 2026-03-13 13:25:26 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7198
Author: @MuzzaiyyanHussain
Created: 1/8/2026
Status: Closed

Base: canaryHead: fix/change-email-verification


📝 Commits (1)

  • 24d5daa Improve robustness of change email verification flow

📊 Changes

2 files changed (+7 additions, -29 deletions)

View changed files

📝 packages/better-auth/src/api/routes/email-verification.test.ts (+1 -0)
📝 packages/better-auth/src/api/routes/update-user.ts (+6 -29)

📄 Description

This change ensures that a user’s email address is only updated after the new email has been successfully verified.

The new email is stored temporarily in a pending state until verification completes, and session mutation during email verification has been removed. All related email verification tests pass and existing behavior remains unchanged.

fixed #7196


Summary by cubic

Finalize a user's email only after successful verification to avoid unverified emails showing up in the session. This aligns the change-email flow with requirements and fixes Linear #7196.

  • Bug Fixes
    • Store new email in pendingEmail with a 30-minute expiry; apply on verification.
    • Remove setSessionCookie updates from updateUser, changePassword, and changeEmail.
    • Send change-email verification tokens with requestType and the unmodified user.
    • Update tests to assert emailVerified is true after confirmation.

Written for commit 24d5daa380. 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/7198 **Author:** [@MuzzaiyyanHussain](https://github.com/MuzzaiyyanHussain) **Created:** 1/8/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/change-email-verification` --- ### 📝 Commits (1) - [`24d5daa`](https://github.com/better-auth/better-auth/commit/24d5daa380c84daa5c315eb2c93f9ec6aab66071) Improve robustness of change email verification flow ### 📊 Changes **2 files changed** (+7 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/email-verification.test.ts` (+1 -0) 📝 `packages/better-auth/src/api/routes/update-user.ts` (+6 -29) </details> ### 📄 Description This change ensures that a user’s email address is only updated after the new email has been successfully verified. The new email is stored temporarily in a pending state until verification completes, and session mutation during email verification has been removed. All related email verification tests pass and existing behavior remains unchanged. fixed #7196 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Finalize a user's email only after successful verification to avoid unverified emails showing up in the session. This aligns the change-email flow with requirements and fixes Linear #7196. - **Bug Fixes** - Store new email in pendingEmail with a 30-minute expiry; apply on verification. - Remove setSessionCookie updates from updateUser, changePassword, and changeEmail. - Send change-email verification tokens with requestType and the unmodified user. - Update tests to assert emailVerified is true after confirmation. <sup>Written for commit 24d5daa380c84daa5c315eb2c93f9ec6aab66071. 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-03-13 13:25:26 -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#7137