[PR #7570] [MERGED] fix(username): dont set other username prop in updateUser #33010

Closed
opened 2026-04-17 23:41:54 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7570
Author: @ping-maxwell
Created: 1/23/2026
Status: Merged
Merged: 3/24/2026
Merged by: @bytaesu

Base: canaryHead: fix/username/dont-set-other-username-prop-in-updateUser


📝 Commits (4)

  • faebbe4 fix(username): dont set other username prop in updateUser
  • 497ce64 fix: username unit tests
  • c7bf475 Merge branch 'canary' into fix/username/dont-set-other-username-prop-in-updateUser
  • 73a09db Merge branch 'canary' into fix/username/dont-set-other-username-prop-in-updateUser

📊 Changes

2 files changed (+3 additions, -5 deletions)

View changed files

📝 packages/better-auth/src/plugins/username/index.ts (+1 -4)
📝 packages/better-auth/src/plugins/username/username.test.ts (+2 -1)

📄 Description

discord: https://discord.com/channels/1288403910284935179/1464063042500296848
Whenever you call updateUser while providing either username or displayUsername then the missing property will be filled with the provided username property. This means in cases where there is a different username & displayUsername on a given user, if calling updateUser and only provided displayUsername, their username will be updated alongside displayUsername.

This hook should only apply to the sign-up endpoint where if a given username field is missing it will default to the provided field.


Summary by cubic

Prevented updateUser from auto-filling the other username field. Defaulting between username and displayUsername now only happens during sign-up.

  • Bug Fixes
    • Restrict username middleware to /sign-up/email only.
    • updateUser no longer mutates the non-provided username/displayUsername.

Written for commit faebbe4a5d. 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/7570 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 1/23/2026 **Status:** ✅ Merged **Merged:** 3/24/2026 **Merged by:** [@bytaesu](https://github.com/bytaesu) **Base:** `canary` ← **Head:** `fix/username/dont-set-other-username-prop-in-updateUser` --- ### 📝 Commits (4) - [`faebbe4`](https://github.com/better-auth/better-auth/commit/faebbe4a5d2536d7f1fd60390196b3b2b35e48fb) fix(username): dont set other username prop in updateUser - [`497ce64`](https://github.com/better-auth/better-auth/commit/497ce641a6116ba8d76b28f150e8bd66941e8c91) fix: username unit tests - [`c7bf475`](https://github.com/better-auth/better-auth/commit/c7bf475b94bc05cc8db5bb06628607222ead7321) Merge branch 'canary' into fix/username/dont-set-other-username-prop-in-updateUser - [`73a09db`](https://github.com/better-auth/better-auth/commit/73a09db494453ecb634e65419b7824b6ff4198a4) Merge branch 'canary' into fix/username/dont-set-other-username-prop-in-updateUser ### 📊 Changes **2 files changed** (+3 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/username/index.ts` (+1 -4) 📝 `packages/better-auth/src/plugins/username/username.test.ts` (+2 -1) </details> ### 📄 Description discord: https://discord.com/channels/1288403910284935179/1464063042500296848 Whenever you call `updateUser` while providing either `username` or `displayUsername` then the missing property will be filled with the provided username property. This means in cases where there is a different username & displayUsername on a given user, if calling `updateUser` and only provided `displayUsername`, their username will be updated alongside displayUsername. This hook should only apply to the sign-up endpoint where if a given username field is missing it will default to the provided field. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Prevented updateUser from auto-filling the other username field. Defaulting between username and displayUsername now only happens during sign-up. - **Bug Fixes** - Restrict username middleware to /sign-up/email only. - updateUser no longer mutates the non-provided username/displayUsername. <sup>Written for commit faebbe4a5d2536d7f1fd60390196b3b2b35e48fb. 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-17 23:41: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#33010