[PR #4582] feat(teams): add optional user details to listTeamMembers #22363

Open
opened 2026-04-15 20:59:37 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4582
Author: @XavierGeerinck
Created: 9/11/2025
Status: 🔄 Open

Base: mainHead: feat-teams-member-list-with-user


📝 Commits (10+)

  • a89d056 feat(teams): add the possibility to list members with their user details
  • d0ca4f3 Revert "chore: bump tailwindcss to v4 (#4681)"
  • 552c242 Reapply "chore: bump tailwindcss to v4 (#4681)"
  • 6781c24 fix: refresh secondary storage sessions on user update (#4522)
  • 2b4751e fix(stripe): onCustomerCreate should be called even if update user isn't returned (#4716)
  • cab9a77 chore: release v1.3.12
  • b91968a docs: add ai tooling
  • 59c188f chore: update chonkie url
  • f5db1ea chore: remove unneeded changes
  • 086303f chore: more fixes

📊 Changes

4 files changed (+142 additions, -3 deletions)

View changed files

📝 docs/content/docs/plugins/organization.mdx (+4 -0)
📝 packages/better-auth/src/plugins/organization/adapter.ts (+36 -2)
📝 packages/better-auth/src/plugins/organization/routes/crud-team.ts (+35 -1)
📝 packages/better-auth/src/plugins/organization/team.test.ts (+67 -0)

📄 Description

This PR enhances the listTeamMembers function by adding an optional includeUser parameter that allows fetching user details (name, email, image) alongside team member data.

Usage

// Basic team members (existing behavior)
const members = await client.organization.listTeamMembers({});

// Team members with user details  
const membersWithUsers = await client.organization.listTeamMembers({
  query: { includeUser: true }
});

Running Tests

pnpm i
cd packages/better-auth
pnpm test src/plugins/organization/team.test.ts

Future Improvements

While the current implementation follows existing patterns and provides good performance for typical use cases, JOIN queries could offer better performance for larger datasets. This would require:

  • Extending the adapter interface to support JOIN operations
  • Updating all database adapters (Kysely, Drizzle, Prisma, etc.)
  • Ensuring cross-database compatibility

This optimization should be considered in a separate PR to maintain focused changes and proper testing across all supported databases.

Testing

  • All 25 tests passing
  • Both includeUser: true and includeUser: false scenarios covered
  • Backward compatibility verified

Summary by cubic

Adds an optional includeUser flag to listTeamMembers to return user details (name, email, image) with each member. Default behavior is unchanged and avoids extra calls when showing member profiles.

  • New Features
    • listTeamMembers accepts includeUser and, when true, includes a user object {id, name, email, image} per member.
    • Adapter and route updated to parse includeUser from the query string ("true") and reflect the optional user field in the response schema.
    • Documentation updated and tests added for both modes.

Written for commit 8cda1e6e5c. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4582 **Author:** [@XavierGeerinck](https://github.com/XavierGeerinck) **Created:** 9/11/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat-teams-member-list-with-user` --- ### 📝 Commits (10+) - [`a89d056`](https://github.com/better-auth/better-auth/commit/a89d0563bb4692bbaa25771a8dc0b6e9a21e8ae5) feat(teams): add the possibility to list members with their user details - [`d0ca4f3`](https://github.com/better-auth/better-auth/commit/d0ca4f35c5911e82e5c9deecd23b953fcc14ee97) Revert "chore: bump tailwindcss to v4 (#4681)" - [`552c242`](https://github.com/better-auth/better-auth/commit/552c242a4d4212ce6ad88279ce97defd2aae413c) Reapply "chore: bump tailwindcss to v4 (#4681)" - [`6781c24`](https://github.com/better-auth/better-auth/commit/6781c24ca4820205e626b7f15baa0a9e0dc13b2a) fix: refresh secondary storage sessions on user update (#4522) - [`2b4751e`](https://github.com/better-auth/better-auth/commit/2b4751eb40bf47d95db64276326ff15639165fbe) fix(stripe): onCustomerCreate should be called even if update user isn't returned (#4716) - [`cab9a77`](https://github.com/better-auth/better-auth/commit/cab9a77656c3842f9bcaabe21542f660226e86ea) chore: release v1.3.12 - [`b91968a`](https://github.com/better-auth/better-auth/commit/b91968a34ec67029c2e810ea979c5715cd9c5cbf) docs: add ai tooling - [`59c188f`](https://github.com/better-auth/better-auth/commit/59c188f93184e0d095beeaade8dd6f1c53746c17) chore: update chonkie url - [`f5db1ea`](https://github.com/better-auth/better-auth/commit/f5db1eaa091f643b376051fad4d4776c501c3d5a) chore: remove unneeded changes - [`086303f`](https://github.com/better-auth/better-auth/commit/086303f6eacab51f02b537d1bf92c5c9ae083039) chore: more fixes ### 📊 Changes **4 files changed** (+142 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/organization.mdx` (+4 -0) 📝 `packages/better-auth/src/plugins/organization/adapter.ts` (+36 -2) 📝 `packages/better-auth/src/plugins/organization/routes/crud-team.ts` (+35 -1) 📝 `packages/better-auth/src/plugins/organization/team.test.ts` (+67 -0) </details> ### 📄 Description This PR enhances the `listTeamMembers` function by adding an optional `includeUser` parameter that allows fetching user details (name, email, image) alongside team member data. ## Usage ```typescript // Basic team members (existing behavior) const members = await client.organization.listTeamMembers({}); // Team members with user details const membersWithUsers = await client.organization.listTeamMembers({ query: { includeUser: true } }); ``` ## Running Tests ```bash pnpm i cd packages/better-auth pnpm test src/plugins/organization/team.test.ts ``` ## Future Improvements While the current implementation follows existing patterns and provides good performance for typical use cases, **JOIN queries could offer better performance** for larger datasets. This would require: - Extending the adapter interface to support JOIN operations - Updating all database adapters (Kysely, Drizzle, Prisma, etc.) - Ensuring cross-database compatibility This optimization should be considered in a **separate PR** to maintain focused changes and proper testing across all supported databases. ## Testing - [x] All 25 tests passing - [x] Both `includeUser: true` and `includeUser: false` scenarios covered - [x] Backward compatibility verified <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds an optional includeUser flag to listTeamMembers to return user details (name, email, image) with each member. Default behavior is unchanged and avoids extra calls when showing member profiles. - **New Features** - listTeamMembers accepts includeUser and, when true, includes a user object {id, name, email, image} per member. - Adapter and route updated to parse includeUser from the query string ("true") and reflect the optional user field in the response schema. - Documentation updated and tests added for both modes. <sup>Written for commit 8cda1e6e5cbf1b380b6163ef3f4069d0f2d05846. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <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:59:37 -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#22363