[PR #2612] [MERGED] fix: exclude current user from username update checks #4399

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/2612
Author: @kylekz
Created: 5/11/2025
Status: Merged
Merged: 7/7/2025
Merged by: @Bekacru

Base: mainHead: fix/exclude-current-user


📝 Commits (4)

📊 Changes

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

View changed files

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

📄 Description

since the username plugin hooks into the updateUser endpoint, it's perfectly reasonable for devs to add this field onto a general user/profile/settings update form with other fields. the plugin currently doesn't discriminate between:

  1. user sign up
  2. user update conflicting with another user
  3. user update conflicting with itself

right now if you wanted to keep the username field within your general updateUser form, you would need to conditionally remove the username property before submission. this pr allows 3 but still blocks 1 and 2


🔄 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/2612 **Author:** [@kylekz](https://github.com/kylekz) **Created:** 5/11/2025 **Status:** ✅ Merged **Merged:** 7/7/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `fix/exclude-current-user` --- ### 📝 Commits (4) - [`0b22173`](https://github.com/better-auth/better-auth/commit/0b221736b9b0090b7e99b61f7d350af9c396dd78) fix: exclude current user from username update checks - [`96132ad`](https://github.com/better-auth/better-auth/commit/96132ada3e5ab0fbade16cda0fe157aeb15cd747) fix lint - [`61bd96d`](https://github.com/better-auth/better-auth/commit/61bd96d5e491e36503c2412ef4731e45f250620a) explicitly check for the session - [`0f0e3d6`](https://github.com/better-auth/better-auth/commit/0f0e3d6c8e52601706561ebe1927f4a30dd63944) fix test ### 📊 Changes **2 files changed** (+49 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/username/index.ts` (+8 -1) 📝 `packages/better-auth/src/plugins/username/username.test.ts` (+41 -2) </details> ### 📄 Description since the username plugin hooks into the `updateUser` endpoint, it's perfectly reasonable for devs to add this field onto a general user/profile/settings update form with other fields. the plugin currently doesn't discriminate between: 1. user sign up 2. user update conflicting with another user 3. user update conflicting with itself right now if you wanted to keep the username field within your general `updateUser` form, you would need to conditionally remove the `username` property before submission. this pr allows 3 but still blocks 1 and 2 --- <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 11:44: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#4399