[GH-ISSUE #1673] Can't invite a member to an organization without inviting them to a team #26182

Closed
opened 2026-04-17 16:39:54 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @sikula on GitHub (Mar 4, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1673

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

This code checks for the teamId parameter when calling inviteMember however this code adds the member information to the invite, but when fetching the member here it will include the teamId and thus automatically add the user to the team when the invite is accepted.

Current vs. Expected behavior

Current behaviour: Adding a member to an organization without specifying the teamId property adds member to a team when the invite is accepted
Expected behaviour: Accepting an invitation without a teamId should add them to the organization without adding them to a team. Accepting an invitation with a teamId should add them to the team

What version of Better Auth are you using?

1.2.2

Provide environment information

OS: Mac
Browser: Brave

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

Backend

Auth config (if applicable)


Additional context

No response

Originally created by @sikula on GitHub (Mar 4, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1673 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce [This code](https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/plugins/organization/routes/crud-invites.ts#L203) checks for the `teamId` parameter when calling `inviteMember` however [this code](https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/plugins/organization/routes/crud-invites.ts#L227) adds the member information to the invite, but when fetching the member [here](https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/plugins/organization/routes/crud-invites.ts#L144) it will include the `teamId` and thus automatically add the user to the team when the invite is accepted. ### Current vs. Expected behavior Current behaviour: Adding a member to an organization without specifying the `teamId` property adds member to a team when the invite is accepted Expected behaviour: Accepting an invitation without a teamId should add them to the organization without adding them to a team. Accepting an invitation with a teamId should add them to the team ### What version of Better Auth are you using? 1.2.2 ### Provide environment information ```bash OS: Mac Browser: Brave ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-17 16:39:54 -05:00
Author
Owner

@sikula commented on GitHub (Mar 4, 2025):

Disregard, issue on my end

<!-- gh-comment-id:2697510246 --> @sikula commented on GitHub (Mar 4, 2025): Disregard, issue on my end
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26182