[GH-ISSUE #1860] Incorrect membershipLimit usage when listing organizations #8949

Closed
opened 2026-04-13 04:11:41 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @BorislavBranimirov on GitHub (Mar 18, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1860

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Set the membershipLimit option to 1 for the organization plugin
  2. Create two or more organizations with the same user
  3. Call auth.api.listOrganizations on the server or client.useListOrganizations on the client
  4. Better auth will only return up to membershipLimit (in this case 1) number of organizations

Current vs. Expected behavior

Current: In the organization plugin, the organizations returned by the '/organization/list' endpoint are limited by the membershipLimit option.

Expected: The membershipLimit option should only affect the maximum number of members allowed in each organization and the 'organization/list' endpoint should return all organizations in which the user is a member. Only the organizationLimit plugin option should be able to limit the organizations of a user.

What version of Better Auth are you using?

1.2.4

Provide environment information

- OS: Mac Sequoia 15.3.2
- Browser: Chrome

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

Backend, Client

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  plugins: [
    organization({
      membershipLimit: 1
    })
  ]
});

Additional context

Caused by 6b5c48b092/packages/better-auth/src/plugins/organization/adapter.ts (L394C16-L394C17)

Originally created by @BorislavBranimirov on GitHub (Mar 18, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1860 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Set the `membershipLimit` option to `1` for the organization plugin 2. Create two or more organizations with the same user 3. Call `auth.api.listOrganizations` on the server or `client.useListOrganizations` on the client 4. Better auth will only return up to `membershipLimit` (in this case 1) number of organizations ### Current vs. Expected behavior Current: In the organization plugin, the organizations returned by the '/organization/list' endpoint are limited by the `membershipLimit` option. Expected: The `membershipLimit` option should only affect the maximum number of members allowed in each organization and the 'organization/list' endpoint should return all organizations in which the user is a member. Only the `organizationLimit` plugin option should be able to limit the organizations of a user. ### What version of Better Auth are you using? 1.2.4 ### Provide environment information ```bash - OS: Mac Sequoia 15.3.2 - Browser: Chrome ``` ### Which area(s) are affected? (Select all that apply) Backend, Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ plugins: [ organization({ membershipLimit: 1 }) ] }); ``` ### Additional context Caused by https://github.com/better-auth/better-auth/blob/6b5c48b092b8760cb26701a30469fdce0d25c726/packages/better-auth/src/plugins/organization/adapter.ts#L394C16-L394C17
GiteaMirror added the lockedbug labels 2026-04-13 04:11:41 -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#8949