[PR #9162] fix: cleanup sessions when deleting users #25377

Open
opened 2026-04-15 22:51:38 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/9162
Author: @ping-maxwell
Created: 4/14/2026
Status: 🔄 Open

Base: mainHead: fix/missing-session-deletion


📝 Commits (4)

  • 2ec08a1 fix: cleanup sessions when deleting users
  • 8425a53 chore: changeset
  • 8633fa0 Merge branch 'main' into fix/missing-session-deletion
  • d225a86 Update packages/better-auth/src/plugins/admin/routes.ts

📊 Changes

6 files changed (+115 additions, -0 deletions)

View changed files

.changeset/chatty-streets-play.md (+5 -0)
📝 packages/better-auth/src/db/secondary-storage.test.ts (+85 -0)
📝 packages/better-auth/src/plugins/admin/routes.ts (+3 -0)
📝 packages/better-auth/src/plugins/anonymous/anon.test.ts (+6 -0)
📝 packages/better-auth/src/plugins/anonymous/error-codes.ts (+2 -0)
📝 packages/better-auth/src/plugins/anonymous/index.ts (+14 -0)

📄 Description

the admin & anonymous plugins have routes which will delete users, but the internal adapter doesn't delete the sessions along with the user like it used to due to a previous fix.
This PR manually calls the internalAdapter to clean the session before deleting the user in each of those missing endpoints.

  • regression unit test

🔄 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/9162 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 4/14/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/missing-session-deletion` --- ### 📝 Commits (4) - [`2ec08a1`](https://github.com/better-auth/better-auth/commit/2ec08a14e8efa7545e41e2d05a07cdfd4e8cf6eb) fix: cleanup sessions when deleting users - [`8425a53`](https://github.com/better-auth/better-auth/commit/8425a53fa574c20f3bae13343cd65c6dda9c9429) chore: changeset - [`8633fa0`](https://github.com/better-auth/better-auth/commit/8633fa05fd66363b588b2e9302fa4f22ed7b71b8) Merge branch 'main' into fix/missing-session-deletion - [`d225a86`](https://github.com/better-auth/better-auth/commit/d225a86f34ed87a806e33073ba022034f0fccc58) Update packages/better-auth/src/plugins/admin/routes.ts ### 📊 Changes **6 files changed** (+115 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/chatty-streets-play.md` (+5 -0) 📝 `packages/better-auth/src/db/secondary-storage.test.ts` (+85 -0) 📝 `packages/better-auth/src/plugins/admin/routes.ts` (+3 -0) 📝 `packages/better-auth/src/plugins/anonymous/anon.test.ts` (+6 -0) 📝 `packages/better-auth/src/plugins/anonymous/error-codes.ts` (+2 -0) 📝 `packages/better-auth/src/plugins/anonymous/index.ts` (+14 -0) </details> ### 📄 Description the `admin` & `anonymous` plugins have routes which will delete users, but the internal adapter doesn't delete the sessions along with the user like it used to due to a previous fix. This PR manually calls the internalAdapter to clean the session before deleting the user in each of those missing endpoints. - [x] regression unit test --- <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 22:51:38 -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#25377