[PR #7251] [CLOSED] refactor: rewrite organization plugin #32775

Closed
opened 2026-04-17 23:30:49 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: canaryHead: feat/org-rewrite


📝 Commits (10+)

📊 Changes

61 files changed (+5666 additions, -23 deletions)

View changed files

📝 docs/components/sidebar-content.tsx (+46 -1)
docs/content/docs/plugins/organization-new/dynamic-access-control.mdx (+8 -0)
docs/content/docs/plugins/organization-new/index.mdx (+88 -0)
docs/content/docs/plugins/organization-new/invitations.mdx (+113 -0)
docs/content/docs/plugins/organization-new/members.mdx (+88 -0)
docs/content/docs/plugins/organization-new/organizations.mdx (+93 -0)
docs/content/docs/plugins/organization-new/roles-permissions.mdx (+163 -0)
docs/content/docs/plugins/organization-new/teams.mdx (+16 -0)
📝 packages/better-auth/src/db/field.ts (+26 -14)
packages/better-auth/src/plugins/organization-new/access/has-permission.ts (+82 -0)
packages/better-auth/src/plugins/organization-new/access/index.ts (+4 -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/addons/dynamic-access-control/index.ts (+10 -0)
packages/better-auth/src/plugins/organization-new/addons/dynamic-access-control/schema.ts (+12 -0)
packages/better-auth/src/plugins/organization-new/addons/dynamic-access-control/types.ts (+16 -0)
packages/better-auth/src/plugins/organization-new/addons/index.ts (+2 -0)
packages/better-auth/src/plugins/organization-new/addons/teams/create-default-team.ts (+60 -0)
packages/better-auth/src/plugins/organization-new/addons/teams/helpers/errors.ts (+8 -0)

...and 41 more files

📄 Description

Organization Rewrite (part 1)

This PR will be the organization plugin rewrite, the goal is to fix all primary issues actively seen in the current organization plugin.
Anything ranging from better access control support, pagination on listing endpoints, optional slugs, to making the organization plugin less bloated for specific cases.

PRs:


Summary by cubic

Refactors the organization plugin with a modular addon system, typed schemas, and new endpoints (createOrganization, updateOrganization, checkSlug, createTeam). Adds default RBAC roles with in-memory permission checks and ships new docs with nested sidebar navigation.

  • New Features

    • Core: resolved options, shared error codes, org middleware, addon hooks/context with priority, schema/endpoint builders.
    • Access control: default statements/roles (owner/admin/member), hasPermission with optional memory cache, dynamic-access-control addon types/schema.
    • Teams addon: default team creation and createTeam endpoint with slug checks, limits, and hooks.
    • APIs: createOrganization, updateOrganization, checkSlug with session/user resolution, org and membership limits, optional slugs.
    • Utilities/Types: buildEndpointSchema (safe nested merges + tests), improved additional-fields inference, helpers (getOrgAdapter, getOrganizationId, getUserFromSessionOrBody, getHook/getAddonHook); docs add “Organization (New)” with subpages and sidebar “New” badge.
  • Migration

    • Slugs configurable via disableSlugs (default false); changing it may require schema/migration updates.
    • Register the new plugin and addons in BetterAuth config (organization({ use: [...] })).

Written for commit 3e8fee21d0. 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/7251 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 1/10/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/org-rewrite` --- ### 📝 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 **61 files changed** (+5666 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `docs/components/sidebar-content.tsx` (+46 -1) ➕ `docs/content/docs/plugins/organization-new/dynamic-access-control.mdx` (+8 -0) ➕ `docs/content/docs/plugins/organization-new/index.mdx` (+88 -0) ➕ `docs/content/docs/plugins/organization-new/invitations.mdx` (+113 -0) ➕ `docs/content/docs/plugins/organization-new/members.mdx` (+88 -0) ➕ `docs/content/docs/plugins/organization-new/organizations.mdx` (+93 -0) ➕ `docs/content/docs/plugins/organization-new/roles-permissions.mdx` (+163 -0) ➕ `docs/content/docs/plugins/organization-new/teams.mdx` (+16 -0) 📝 `packages/better-auth/src/db/field.ts` (+26 -14) ➕ `packages/better-auth/src/plugins/organization-new/access/has-permission.ts` (+82 -0) ➕ `packages/better-auth/src/plugins/organization-new/access/index.ts` (+4 -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/addons/dynamic-access-control/index.ts` (+10 -0) ➕ `packages/better-auth/src/plugins/organization-new/addons/dynamic-access-control/schema.ts` (+12 -0) ➕ `packages/better-auth/src/plugins/organization-new/addons/dynamic-access-control/types.ts` (+16 -0) ➕ `packages/better-auth/src/plugins/organization-new/addons/index.ts` (+2 -0) ➕ `packages/better-auth/src/plugins/organization-new/addons/teams/create-default-team.ts` (+60 -0) ➕ `packages/better-auth/src/plugins/organization-new/addons/teams/helpers/errors.ts` (+8 -0) _...and 41 more files_ </details> ### 📄 Description ## Organization Rewrite (part 1) This PR will be the organization plugin rewrite, the goal is to fix all primary issues actively seen in the current organization plugin. Anything ranging from better access control support, pagination on listing endpoints, optional slugs, to making the organization plugin less bloated for specific cases. ### PRs: * [part 1](https://github.com/better-auth/better-auth/pull/7251) - You're here. * [part 2](https://github.com/better-auth/better-auth/pull/7544) * [part 3](https://github.com/better-auth/better-auth/pull/7591) * [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) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Refactors the organization plugin with a modular addon system, typed schemas, and new endpoints (createOrganization, updateOrganization, checkSlug, createTeam). Adds default RBAC roles with in-memory permission checks and ships new docs with nested sidebar navigation. - New Features - Core: resolved options, shared error codes, org middleware, addon hooks/context with priority, schema/endpoint builders. - Access control: default statements/roles (owner/admin/member), hasPermission with optional memory cache, dynamic-access-control addon types/schema. - Teams addon: default team creation and createTeam endpoint with slug checks, limits, and hooks. - APIs: createOrganization, updateOrganization, checkSlug with session/user resolution, org and membership limits, optional slugs. - Utilities/Types: buildEndpointSchema (safe nested merges + tests), improved additional-fields inference, helpers (getOrgAdapter, getOrganizationId, getUserFromSessionOrBody, getHook/getAddonHook); docs add “Organization (New)” with subpages and sidebar “New” badge. - Migration - Slugs configurable via disableSlugs (default false); changing it may require schema/migration updates. - Register the new plugin and addons in BetterAuth config (organization({ use: [...] })). <sup>Written for commit 3e8fee21d0e0bd7befe009b649ad8435e15d3463. 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-04-17 23:30:49 -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#32775