Custom admin role not considered an admin #922

Closed
opened 2026-03-13 08:10:02 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @danielfr9 on GitHub (Mar 26, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Configure better-auth as per the docs
  2. Add the admin plugin
  3. Add the adminRoles property with admin and superAdmin as roles
  4. Create a user with the superAdmin role
  5. Use the superAdmin user to call the function listUsers provided by the auth object
  6. An error with code YOU_ARE_NOT_ALLOWED_TO_LIST_USERS is returned

Current vs. Expected behavior

The superAdmin role should be treated as an admin role, inheriting all the permissions necessary for an admin by default. This was the original behavior prior to v1.2.0.

Image

What version of Better Auth are you using?

1.2.4

Provide environment information

- OS [Windows 10]
- Browser [Zen Browser]
- Node version [v20.17.0]

Which area(s) are affected? (Select all that apply)

Backend, Client

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { nextCookies } from "better-auth/next-js";
import { admin } from "better-auth/plugins/admin";
import { db } from "@/server/db";
import { drizzleAdapter } from "better-auth/adapters/drizzle";

export const auth = betterAuth({
  database: drizzleAdapter(db, {
    provider: "pg", 
  }),
  plugins: [
    admin({
      adminRoles: ["admin", "superAdmin"],
    }),
    nextCookies(), 
  ],
});

Additional context

The error received:

Image

It's worth noting that adding the adminUserIds property with the ID of the superAdmin works fine.

Originally created by @danielfr9 on GitHub (Mar 26, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Configure better-auth as per the docs 2. Add the admin plugin 3. Add the adminRoles property with **admin** and **superAdmin** as roles 4. Create a user with the **superAdmin** role 5. Use the superAdmin user to call the function **listUsers** provided by the auth object 6. An error with code **YOU_ARE_NOT_ALLOWED_TO_LIST_USERS** is returned ### Current vs. Expected behavior The **superAdmin** role should be treated as an admin role, inheriting all the permissions necessary for an admin by default. This was the original behavior prior to **v1.2.0**. ![Image](https://github.com/user-attachments/assets/68187fa6-1a67-422a-8239-78f1aac8cec3) ### What version of Better Auth are you using? 1.2.4 ### Provide environment information ```bash - OS [Windows 10] - Browser [Zen Browser] - Node version [v20.17.0] ``` ### Which area(s) are affected? (Select all that apply) Backend, Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { nextCookies } from "better-auth/next-js"; import { admin } from "better-auth/plugins/admin"; import { db } from "@/server/db"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "pg", }), plugins: [ admin({ adminRoles: ["admin", "superAdmin"], }), nextCookies(), ], }); ``` ### Additional context The error received: ![Image](https://github.com/user-attachments/assets/9d4478f3-8563-4f86-87a5-e708402d9f74) It's worth noting that adding the **adminUserIds** property with the ID of the superAdmin works fine.
GiteaMirror added the bug label 2026-03-13 08:10:02 -05:00
Author
Owner

@Bekacru commented on GitHub (Mar 27, 2025):

since 1.2, the admin plugin requires access control definition for additional roles
https://www.better-auth.com/docs/plugins/admin#access-control

@Bekacru commented on GitHub (Mar 27, 2025): since 1.2, the admin plugin requires access control definition for additional roles https://www.better-auth.com/docs/plugins/admin#access-control
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#922