[GH-ISSUE #747] Admin Plugin: user can login after ban #8408

Closed
opened 2026-04-13 03:28:41 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @erickleinde on GitHub (Dec 3, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/747

Describe the bug
After a user was banned, they were still able to log in

To Reproduce
Steps to reproduce the behavior:

  1. Ban user
  2. login with your banned user

Expected behavior
User should no longer be able to log in after the ban

Screenshots
Screenshot from DB:
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Google Chrome
  • Version: 131.0.6778.86
Originally created by @erickleinde on GitHub (Dec 3, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/747 **Describe the bug** After a user was banned, they were still able to log in **To Reproduce** Steps to reproduce the behavior: 1. Ban user 2. login with your banned user **Expected behavior** User should no longer be able to log in after the ban **Screenshots** Screenshot from DB: ![image](https://github.com/user-attachments/assets/1dd085c9-754c-4923-b20e-237b02abafba) **Desktop (please complete the following information):** - OS: Windows 10 - Browser: Google Chrome - Version: 131.0.6778.86
GiteaMirror added the locked label 2026-04-13 03:28:41 -05:00
Author
Owner

@Bekacru commented on GitHub (Dec 3, 2024):

The ban protection is enforced at the session creation level. This means that just before a session is created, if the user is banned, a session will not be generated for them. However, they can still go through the authentication flow—for example, if they are using OAuth, or they might still receive an email OTP if you are using email-otp. The ban is enforced precisely when the authentication method attempts to generate a session.

If, for any reason, this is bypassed and a session is actually being generated for a banned user, please let me know which authentication method you are using

<!-- gh-comment-id:2514716056 --> @Bekacru commented on GitHub (Dec 3, 2024): The ban protection is enforced at the session creation level. This means that just before a session is created, if the user is banned, a session will not be generated for them. However, they can still go through the authentication flow—for example, if they are using OAuth, or they might still receive an email OTP if you are using email-otp. The ban is enforced precisely when the authentication method attempts to generate a session. If, for any reason, this is bypassed and a session is actually being generated for a banned user, please let me know which authentication method you are using
Author
Owner

@erickleinde commented on GitHub (Dec 3, 2024):

Ah sorry, my mistake. I was using an old version of better auth. 😅 everything works with the current one. 🙂

<!-- gh-comment-id:2514856822 --> @erickleinde commented on GitHub (Dec 3, 2024): Ah sorry, my mistake. I was using an old version of better auth. 😅 everything works with the current one. 🙂
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8408