[PR #1794] [MERGED] feat(organization): Add teamId in addMember #20898

Closed
opened 2026-04-15 20:00:14 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/1794
Author: @Netrifier
Created: 3/12/2025
Status: Merged
Merged: 3/13/2025
Merged by: @Bekacru

Base: mainHead: feat-organization-add-teamid-in-add-member


📝 Commits (3)

  • feb767a feat(organization): Add teamId in addMember
  • 4299c88 docs(organization): Add teamId in addMember function
  • c62c9d6 Merge branch 'main' into feat-organization-add-teamid-in-add-member

📊 Changes

4 files changed (+72 additions, -19 deletions)

View changed files

📝 docs/content/docs/plugins/organization.mdx (+2 -1)
📝 packages/better-auth/src/plugins/organization/adapter.ts (+38 -15)
📝 packages/better-auth/src/plugins/organization/routes/crud-members.ts (+24 -1)
📝 packages/better-auth/src/plugins/organization/routes/crud-team.ts (+8 -2)

📄 Description

  • Added teamId option to addMember
await auth.api.addMember({
    body: {
      organizationId: <org_id>,
      userId: <user_id>,
      role: "admin",
      teamId: <team_id>,
});
  • Updated docs
  • Changed the findTeamById org adapter function to take additional arguments
findTeamById: async <IncludeMembers extends boolean>({
		teamId,
		organizationId,
		includeTeamMembers,
	}: {
		teamId: string;
		// optionally add a organizationId to search the team by orgId
		organizationId?: string;
		// Option to include team members as previously members where queried from db regardless of whether they were used
		includeTeamMembers?: IncludeMembers;
	// Typescript type to conditionally add members to return type depending on includeTeamMembers
	}): Promise<(Team & (IncludeMembers extends true ? { members: Member[] } : {})) | null>

---

<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/1794 **Author:** [@Netrifier](https://github.com/Netrifier) **Created:** 3/12/2025 **Status:** ✅ Merged **Merged:** 3/13/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `feat-organization-add-teamid-in-add-member` --- ### 📝 Commits (3) - [`feb767a`](https://github.com/better-auth/better-auth/commit/feb767a2830fd63e1917aed8d2de5737b4074cc3) feat(organization): Add teamId in addMember - [`4299c88`](https://github.com/better-auth/better-auth/commit/4299c88451eaecd9e20fd4be1e5f67808ca0c4d2) docs(organization): Add teamId in addMember function - [`c62c9d6`](https://github.com/better-auth/better-auth/commit/c62c9d6348996247dec3c5f43c6f062fdbecf54a) Merge branch 'main' into feat-organization-add-teamid-in-add-member ### 📊 Changes **4 files changed** (+72 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/organization.mdx` (+2 -1) 📝 `packages/better-auth/src/plugins/organization/adapter.ts` (+38 -15) 📝 `packages/better-auth/src/plugins/organization/routes/crud-members.ts` (+24 -1) 📝 `packages/better-auth/src/plugins/organization/routes/crud-team.ts` (+8 -2) </details> ### 📄 Description - Added `teamId` option to `addMember` ```ts await auth.api.addMember({ body: { organizationId: <org_id>, userId: <user_id>, role: "admin", teamId: <team_id>, }); ``` - Updated docs - Changed the `findTeamById` org adapter function to take additional arguments ```ts findTeamById: async <IncludeMembers extends boolean>({ teamId, organizationId, includeTeamMembers, }: { teamId: string; // optionally add a organizationId to search the team by orgId organizationId?: string; // Option to include team members as previously members where queried from db regardless of whether they were used includeTeamMembers?: IncludeMembers; // Typescript type to conditionally add members to return type depending on includeTeamMembers }): Promise<(Team & (IncludeMembers extends true ? { members: Member[] } : {})) | null> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 20:00:14 -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#20898