[GH-ISSUE #1746] Organization update does not error on missing permissions #8897

Closed
opened 2026-04-13 04:08:43 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @vniehues on GitHub (Mar 9, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1746

Issue: Organization update does not error on missing permissions

Problem Description

The organization.update method does not properly error when a user lacks the necessary permissions.

The role check seems to work because the updates are not actually committed, but the response indicates success when it should instead error because of missing permissions.

Expected Behavior

When a user without the organization: ["update"] permission attempts to update an organization, the API should return an error.

Actual Behavior

const permissionResult = await authClient.organization.hasPermission({
  permission: {
    organization: ["update"]
  }
})

This correctly returns:

{
  data: {
    {error: null, success: false}
  }, 
  error: null
}

However, when attempting to update:

const updateResult = await authClient.organization.update({
  data: {
    name: "new org name"
  }
})

It incorrectly returns:

{data: null, error: null}

It also takes the onSuccess path in the fetch options, making it difficult to properly manage feedback to the user.

Additional Context

This is a slimmed down version of my custom access control & roles:

const statement = {
    ...defaultStatements,
    project: ["create", "update", "delete"],
} as const;

export const ac = createAccessControl(statement);

export const authRoles = {
    estimator: ac.newRole({
        ...memberAc.statements,
        project: ["update"],
    }),
    managingDirector: ac.newRole({
        ...adminAc.statements,
        organization: ["update"]
    })
} as const;

And this is a slimmed down version of the server config:

const orgPluginConfig = organization({
    allowUserToCreateOrganization: false,
    organizationLimit: 1,
    creatorRole: authRoleNames.managingDirector,
    ac: ac,
    roles: authRoles,
});
Originally created by @vniehues on GitHub (Mar 9, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1746 # Issue: Organization update does not error on missing permissions ## Problem Description The `organization.update` method does not properly error when a user lacks the necessary permissions. The role check seems to work because the updates are not actually committed, but the response indicates success when it should instead error because of missing permissions. ### Expected Behavior When a user without the `organization: ["update"]` permission attempts to update an organization, the API should return an error. ### Actual Behavior ```javascript const permissionResult = await authClient.organization.hasPermission({ permission: { organization: ["update"] } }) ``` This correctly returns: ```javascript { data: { {error: null, success: false} }, error: null } ``` However, when attempting to update: ```javascript const updateResult = await authClient.organization.update({ data: { name: "new org name" } }) ``` It incorrectly returns: ```javascript {data: null, error: null} ``` It also takes the `onSuccess` path in the fetch options, making it difficult to properly manage feedback to the user. ## Additional Context This is a slimmed down version of my custom access control & roles: ```javascript const statement = { ...defaultStatements, project: ["create", "update", "delete"], } as const; export const ac = createAccessControl(statement); export const authRoles = { estimator: ac.newRole({ ...memberAc.statements, project: ["update"], }), managingDirector: ac.newRole({ ...adminAc.statements, organization: ["update"] }) } as const; ``` And this is a slimmed down version of the server config: ```javascript const orgPluginConfig = organization({ allowUserToCreateOrganization: false, organizationLimit: 1, creatorRole: authRoleNames.managingDirector, ac: ac, roles: authRoles, }); ```
GiteaMirror added the locked label 2026-04-13 04:08:43 -05:00
Author
Owner

@vniehues commented on GitHub (Mar 9, 2025):

Fixed by this commit: e99931fae8 and tested with this PR: #1748

<!-- gh-comment-id:2708888817 --> @vniehues commented on GitHub (Mar 9, 2025): Fixed by this commit: https://github.com/better-auth/better-auth/commit/e99931fae81f36e338b55dc61eb5e71bce420378 and tested with this PR: [#1748](https://github.com/better-auth/better-auth/pull/1748)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8897