[PR #4649] [MERGED] fix: check if user exists before banning the user #5505

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4649
Author: @anmol-fzr
Created: 9/14/2025
Status: Merged
Merged: 9/15/2025
Merged by: @himself65

Base: canaryHead: fix/admin-user-ban-check


📝 Commits (3)

  • 0b472dd Fix: Checks if user exists before banning the user
  • 1fca931 Merge branch 'canary' into fix/admin-user-ban-check
  • 4756dcc test: fix

📊 Changes

2 files changed (+96 additions, -2 deletions)

View changed files

📝 packages/better-auth/src/plugins/admin/admin.test.ts (+85 -2)
📝 packages/better-auth/src/plugins/admin/admin.ts (+11 -0)

📄 Description

Fixes: https://github.com/better-auth/better-auth/issues/4648

Added a simple check before updating the user for banning

  • If user is not found return a 404 NOT_FOUND error

Summary by cubic

Banning a user now verifies the target exists. If not found, it returns 404 NOT_FOUND (USER_NOT_FOUND).

  • Bug Fixes
    • Check user via internalAdapter.findUserById before ban.
    • Keep self-ban guard; nonexistent users are rejected first.

🔄 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/4649 **Author:** [@anmol-fzr](https://github.com/anmol-fzr) **Created:** 9/14/2025 **Status:** ✅ Merged **Merged:** 9/15/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/admin-user-ban-check` --- ### 📝 Commits (3) - [`0b472dd`](https://github.com/better-auth/better-auth/commit/0b472dd75b2ba608b2e7e88695515617173383b8) Fix: Checks if user exists before banning the user - [`1fca931`](https://github.com/better-auth/better-auth/commit/1fca931400adc0df7338b92454cebce38f98ded6) Merge branch 'canary' into fix/admin-user-ban-check - [`4756dcc`](https://github.com/better-auth/better-auth/commit/4756dcc78572ea646d14c664f58e79c53fa6a948) test: fix ### 📊 Changes **2 files changed** (+96 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/admin/admin.test.ts` (+85 -2) 📝 `packages/better-auth/src/plugins/admin/admin.ts` (+11 -0) </details> ### 📄 Description Fixes: https://github.com/better-auth/better-auth/issues/4648 Added a simple check before updating the user for banning - If user is not found return a 404 NOT_FOUND error <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Banning a user now verifies the target exists. If not found, it returns 404 NOT_FOUND (USER_NOT_FOUND). - **Bug Fixes** - Check user via internalAdapter.findUserById before ban. - Keep self-ban guard; nonexistent users are rejected first. <!-- 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 12:25:21 -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#5505