[GH-ISSUE #2100] updateMemberRole only works if the updating user has a single role #9052

Closed
opened 2026-04-13 04:20:21 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @dustin-we on GitHub (Apr 3, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2100

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

To reproduce:

  1. Create a better-auth instance with the organizations plugin. I don't think the database matters.
  2. Create a organization
  3. Update your own member role to two roles
    const { error } = await authClient.organization.updateMemberRole({ memberId: "YOUR_MEMBER_ID", role: ["owner", "admin"] });
  4. Do step 3 again

Current vs. Expected behavior

Currently:
The first time the member role is set, the "role" column in the "member" table will be set to "owner,admin", which is what I would expect.
The second time you do it, you get an error ROLE_NOT_FOUND.

I think the code for this endpoint is checking if the role "owner,admin" is present, not either one of them.

What version of Better Auth are you using?

1.2.5

Provide environment information

- OS: MacOs 15.4
- Browser: Chrome

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"

export const auth = betterAuth({
  database: { dialect, type: "postgres" },
  emailAndPassword: {
    enabled: true,
    disableSignUp: true,
    requireEmailVerification: false,
    maxPasswordLength: 100,
    minPasswordLength: 8,
  },
  socialProviders: {
    microsoft: {
      enabled: true,
      clientId: process.env.MICROSOFT_CLIENT_ID as string,
      clientSecret: process.env.MICROSOFT_CLIENT_SECRET as string,
      tenantId: process.env.MICROSOFT_TENANT_ID as string,

      // tenantId: "common",
    },
  },
  plugins: [organization({ ac, roles }), admin()],
});

Additional context

In my example, I added custom roles to my better-auth instance. This bug occurs even if you didnt. As you can see in the example, I used the standard roles, 'admin', 'owner'

Originally created by @dustin-we on GitHub (Apr 3, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2100 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce To reproduce: 1. Create a better-auth instance with the organizations plugin. I don't think the database matters. 2. Create a organization 3. Update your own member role to two roles ` const { error } = await authClient.organization.updateMemberRole({ memberId: "YOUR_MEMBER_ID", role: ["owner", "admin"] }); ` 4. Do step 3 again ### Current vs. Expected behavior Currently: The first time the member role is set, the "role" column in the "member" table will be set to "owner,admin", which is what I would expect. The second time you do it, you get an error ROLE_NOT_FOUND. I think the code for this endpoint is checking if the role "owner,admin" is present, not either one of them. ### What version of Better Auth are you using? 1.2.5 ### Provide environment information ```bash - OS: MacOs 15.4 - Browser: Chrome ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ database: { dialect, type: "postgres" }, emailAndPassword: { enabled: true, disableSignUp: true, requireEmailVerification: false, maxPasswordLength: 100, minPasswordLength: 8, }, socialProviders: { microsoft: { enabled: true, clientId: process.env.MICROSOFT_CLIENT_ID as string, clientSecret: process.env.MICROSOFT_CLIENT_SECRET as string, tenantId: process.env.MICROSOFT_TENANT_ID as string, // tenantId: "common", }, }, plugins: [organization({ ac, roles }), admin()], }); ``` ### Additional context In my example, I added custom roles to my better-auth instance. This bug occurs even if you didnt. As you can see in the example, I used the standard roles, 'admin', 'owner'
GiteaMirror added the lockedbug labels 2026-04-13 04:20: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#9052