[PR #5833] [MERGED] fix(phone-number): shouldn't allow updating phone number on /update-user endpoint #23161

Closed
opened 2026-04-15 21:31:24 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5833
Author: @ping-maxwell
Created: 11/7/2025
Status: Merged
Merged: 11/7/2025
Merged by: @Bekacru

Base: canaryHead: fix/update-user-phoneNumber-should-reset-verified


📝 Commits (3)

  • c3da013 fix(phone-number): calling updateUser with phoneNumber should set phoneNumberVerified to false
  • 523195a Update phone-number.test.ts
  • 50a41e4 fix: disable phone number update

📊 Changes

3 files changed (+97 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/plugins/anonymous/index.ts (+1 -0)
📝 packages/better-auth/src/plugins/phone-number/index.ts (+18 -1)
📝 packages/better-auth/src/plugins/phone-number/phone-number.test.ts (+78 -0)

📄 Description

Right now you can call authClient.updateUser({phoneNumber: "123"}) and if the user previously had an older phone number verified, the phoneNumberVerified state stays true, despite updating to an unverified phone number.

This PR fixes this and introduces tests.


Summary by cubic

Prevents updating a user's phone number via updateUser. Requests now return 400 and keep phoneNumber and phoneNumberVerified unchanged.

  • Bug Fixes
    • Block phoneNumber updates on /update-user via a before hook; returns "Phone number cannot be updated".
    • Added tests to ensure the phone number can't be changed and verification state remains intact.

Written for commit 50a41e4309. Summary will update automatically 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/5833 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 11/7/2025 **Status:** ✅ Merged **Merged:** 11/7/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/update-user-phoneNumber-should-reset-verified` --- ### 📝 Commits (3) - [`c3da013`](https://github.com/better-auth/better-auth/commit/c3da013003cde2bee300284a3b09edb58304d877) fix(phone-number): calling `updateUser` with `phoneNumber` should set `phoneNumberVerified` to false - [`523195a`](https://github.com/better-auth/better-auth/commit/523195a8fe4350895f77893cb8f1bef1156b75a0) Update phone-number.test.ts - [`50a41e4`](https://github.com/better-auth/better-auth/commit/50a41e4309602d03bccdcb1de6e7785320245a01) fix: disable phone number update ### 📊 Changes **3 files changed** (+97 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/anonymous/index.ts` (+1 -0) 📝 `packages/better-auth/src/plugins/phone-number/index.ts` (+18 -1) 📝 `packages/better-auth/src/plugins/phone-number/phone-number.test.ts` (+78 -0) </details> ### 📄 Description Right now you can call `authClient.updateUser({phoneNumber: "123"})` and if the user previously had an older phone number verified, the `phoneNumberVerified` state stays `true`, despite updating to an unverified phone number. This PR fixes this and introduces tests. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Prevents updating a user's phone number via updateUser. Requests now return 400 and keep phoneNumber and phoneNumberVerified unchanged. - **Bug Fixes** - Block phoneNumber updates on /update-user via a before hook; returns "Phone number cannot be updated". - Added tests to ensure the phone number can't be changed and verification state remains intact. <sup>Written for commit 50a41e4309602d03bccdcb1de6e7785320245a01. Summary will update automatically 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-15 21:31:24 -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#23161