[PR #7591] [CLOSED] refactor: rewrite organization plugin (pt3) #7425

Closed
opened 2026-03-13 13:35:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7591
Author: @ping-maxwell
Created: 1/24/2026
Status: Closed

Base: canaryHead: refactor/org-rewrite-part3


📝 Commits (10+)

📊 Changes

95 files changed (+13511 additions, -27 deletions)

View changed files

📝 docs/components/side-bar.tsx (+1 -5)
📝 docs/components/sidebar-content.tsx (+64 -0)
📝 docs/content/docs/plugins/organization-old.mdx (+0 -0)
docs/content/docs/plugins/organization/access-control.mdx (+163 -0)
docs/content/docs/plugins/organization/active-organizations.mdx (+5 -0)
docs/content/docs/plugins/organization/dynamic-access-control.mdx (+8 -0)
docs/content/docs/plugins/organization/index.mdx (+102 -0)
docs/content/docs/plugins/organization/invitations.mdx (+365 -0)
docs/content/docs/plugins/organization/members.mdx (+37 -0)
docs/content/docs/plugins/organization/organization-identifiers.mdx (+100 -0)
docs/content/docs/plugins/organization/organizations.mdx (+410 -0)
docs/content/docs/plugins/organization/teams.mdx (+6 -0)
📝 packages/better-auth/src/client/plugins/index.ts (+1 -0)
📝 packages/better-auth/src/db/field.ts (+26 -14)
packages/better-auth/src/plugins/organization-new/access/has-permission.ts (+83 -0)
packages/better-auth/src/plugins/organization-new/access/index.ts (+5 -0)
packages/better-auth/src/plugins/organization-new/access/permission.ts (+53 -0)
packages/better-auth/src/plugins/organization-new/access/statement.ts (+41 -0)
packages/better-auth/src/plugins/organization-new/access/types.ts (+9 -0)
packages/better-auth/src/plugins/organization-new/access/utils.ts (+3 -0)

...and 75 more files

📄 Description

Organization Rewrite (part 3)

This PR is the organization plugin rewrite, the goal is to restructure the organization plugin code in both file structure and code cleanness. This rewrite will also include new features and minor performance improvements in specific areas.

PRs:

Todo

  • New Feature implementation
    • defaultOrganizationIdField support
    • Disable slug on organizations
    • Get organization endpoint
    • Documentation rewrite + sub-page support
    • Enable slug on teams
    • Additional fields support for teamMember
    • Banning organizations?
    • Create org on sign-up
    • Functionality to get invitation URL without sending email (even if sendInvitation) is defined.
  • Endpoints
    • Organizations
      • Check organization slug
      • Create org
      • Delete org
      • Get full org
      • Get org
      • List orgs (+pagination support)
      • Set active org
      • Update org
    • Invitations
      • Accept invitation
      • Create invitation
      • Reject invitation
      • Cancel invitation
      • Get invitation
      • List invitation (+pagination support)
      • List user invitations (+pagination support)
    • Members
      • Add member
      • Remove member
      • Update member role
      • Get active member
      • Leave organization
      • List members (+pagination support)
      • Get active member role
    • Teams
      • Create team
      • Remove team
      • Update team
      • List organization teams (+pagination support)
      • Set active team
      • List user teams (+pagination support)
      • List team members (+pagination support)
      • Add team member
      • Remove team member
    • Dynamic Access Control
      • Create org role
      • Delete org role
      • List org roles (+pagination support)
      • Get org role
      • Update org role

Summary by cubic

Rewrites the Organization plugin with a modular RBAC system, new endpoints, and addons for teams and dynamic access control. Updates docs and client exports to support the new API.

  • New Features

    • Core org endpoints: create, update, delete, get, get full, list, set active, and check slug.
    • Invitations: create, accept, reject, cancel, get, list, and list user invitations with limits, expiry, and email hook.
    • RBAC: default roles (owner/admin/member), permission checks, and dynamic access control addon.
    • Teams addon: default team creation and a create-team endpoint.
  • Migration

    • Use organization() from the new plugin and add organizationNewClient on the client.
    • If using slugs as IDs, set defaultOrganizationIdField to "slug" and keep slugs enabled.
    • Define additional fields via plugin schema options; adjust adapters accordingly.
    • Docs moved under /docs/plugins/organization with updated navigation.

Written for commit 18a4ead556. Summary will update 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/7591 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 1/24/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `refactor/org-rewrite-part3` --- ### 📝 Commits (10+) - [`3d34ee3`](https://github.com/better-auth/better-auth/commit/3d34ee3e93035f5dfa83e23a2ded5f921a0359ad) wip - [`84d94a4`](https://github.com/better-auth/better-auth/commit/84d94a47c47dbfb00a6dfae7bd708a6a204fc68c) Update build-endpoint-schema.ts - [`bd84663`](https://github.com/better-auth/better-auth/commit/bd846631166f675e88be8f1dd3be21ee10be529f) update: improve build-endpoint-schema - [`9662e67`](https://github.com/better-auth/better-auth/commit/9662e674b4eaf6ad123c649255d5269fc95cbe94) Merge branch 'canary' into feat/org-rewrite - [`e50272b`](https://github.com/better-auth/better-auth/commit/e50272bb8672386f01097d6e96fa3e1b57a19aa7) fix: count-org adapter function to use member table - [`c025cf7`](https://github.com/better-auth/better-auth/commit/c025cf7136bec34a7ccf4ad9bb4264a4ea47be2d) Merge branch 'feat/org-rewrite' of https://github.com/ping-maxwell/better-auth into feat/org-rewrite - [`93a0670`](https://github.com/better-auth/better-auth/commit/93a0670f6f679fb4f76a3cc8967166ab602ba16f) Merge branch 'canary' into feat/org-rewrite - [`15bba08`](https://github.com/better-auth/better-auth/commit/15bba08f059d42c488c81f5050896a347e0c6282) update: create-org first-stage completed - [`36e975f`](https://github.com/better-auth/better-auth/commit/36e975f50b997711e990860fc066902ac84fe50b) Update build-endpoint-schema.ts - [`3cba580`](https://github.com/better-auth/better-auth/commit/3cba5809aec688ceaf6d81b7f37293c1f1818665) fix: create deep copy to avoid deep mutation ### 📊 Changes **95 files changed** (+13511 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `docs/components/side-bar.tsx` (+1 -5) 📝 `docs/components/sidebar-content.tsx` (+64 -0) 📝 `docs/content/docs/plugins/organization-old.mdx` (+0 -0) ➕ `docs/content/docs/plugins/organization/access-control.mdx` (+163 -0) ➕ `docs/content/docs/plugins/organization/active-organizations.mdx` (+5 -0) ➕ `docs/content/docs/plugins/organization/dynamic-access-control.mdx` (+8 -0) ➕ `docs/content/docs/plugins/organization/index.mdx` (+102 -0) ➕ `docs/content/docs/plugins/organization/invitations.mdx` (+365 -0) ➕ `docs/content/docs/plugins/organization/members.mdx` (+37 -0) ➕ `docs/content/docs/plugins/organization/organization-identifiers.mdx` (+100 -0) ➕ `docs/content/docs/plugins/organization/organizations.mdx` (+410 -0) ➕ `docs/content/docs/plugins/organization/teams.mdx` (+6 -0) 📝 `packages/better-auth/src/client/plugins/index.ts` (+1 -0) 📝 `packages/better-auth/src/db/field.ts` (+26 -14) ➕ `packages/better-auth/src/plugins/organization-new/access/has-permission.ts` (+83 -0) ➕ `packages/better-auth/src/plugins/organization-new/access/index.ts` (+5 -0) ➕ `packages/better-auth/src/plugins/organization-new/access/permission.ts` (+53 -0) ➕ `packages/better-auth/src/plugins/organization-new/access/statement.ts` (+41 -0) ➕ `packages/better-auth/src/plugins/organization-new/access/types.ts` (+9 -0) ➕ `packages/better-auth/src/plugins/organization-new/access/utils.ts` (+3 -0) _...and 75 more files_ </details> ### 📄 Description ## Organization Rewrite (part 3) This PR is the organization plugin rewrite, the goal is to restructure the organization plugin code in both file structure and code cleanness. This rewrite will also include new features and minor performance improvements in specific areas. ### PRs: * [part 1](https://github.com/better-auth/better-auth/pull/7251) * [part 2](https://github.com/better-auth/better-auth/pull/7544) * [part 3](https://github.com/better-auth/better-auth/pull/7591) - You're here. * [part 4](https://github.com/better-auth/better-auth/pull/7601) * [part 5](https://github.com/better-auth/better-auth/pull/7628) * [part 6](https://github.com/better-auth/better-auth/pull/7886) ### Todo - [ ] New Feature implementation - [x] `defaultOrganizationIdField` support - [x] Disable slug on organizations - [x] Get organization endpoint - [x] Documentation rewrite + sub-page support - [ ] Enable slug on teams - [ ] Additional fields support for `teamMember` - [ ] Banning organizations? - [ ] Create org on sign-up - [ ] Functionality to get invitation URL without sending email (even if `sendInvitation`) is defined. - [ ] Endpoints - Organizations - [x] Check organization slug - [x] Create org - [x] Delete org - [x] Get full org - [x] Get org - [x] List orgs (+pagination support) - [x] Set active org - [x] Update org - Invitations - [x] Accept invitation - [x] Create invitation - [x] Reject invitation - [x] Cancel invitation - [x] Get invitation - [x] List invitation (+pagination support) - [x] List user invitations (+pagination support) - Members - [ ] Add member - [ ] Remove member - [ ] Update member role - [ ] Get active member - [ ] Leave organization - [ ] List members (+pagination support) - [ ] Get active member role - Teams - [x] Create team - [ ] Remove team - [ ] Update team - [ ] List organization teams (+pagination support) - [ ] Set active team - [ ] List user teams (+pagination support) - [ ] List team members (+pagination support) - [ ] Add team member - [ ] Remove team member - Dynamic Access Control - [ ] Create org role - [ ] Delete org role - [ ] List org roles (+pagination support) - [ ] Get org role - [ ] Update org role <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Rewrites the Organization plugin with a modular RBAC system, new endpoints, and addons for teams and dynamic access control. Updates docs and client exports to support the new API. - **New Features** - Core org endpoints: create, update, delete, get, get full, list, set active, and check slug. - Invitations: create, accept, reject, cancel, get, list, and list user invitations with limits, expiry, and email hook. - RBAC: default roles (owner/admin/member), permission checks, and dynamic access control addon. - Teams addon: default team creation and a create-team endpoint. - **Migration** - Use organization() from the new plugin and add organizationNewClient on the client. - If using slugs as IDs, set defaultOrganizationIdField to "slug" and keep slugs enabled. - Define additional fields via plugin schema options; adjust adapters accordingly. - Docs moved under /docs/plugins/organization with updated navigation. <sup>Written for commit 18a4ead5569d0b091c278b9aef68c2cc92227b2e. Summary will update 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-03-13 13:35:55 -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#7425