[PR #4707] [MERGED] fix(organization): decouple client and server permission checks #31140

Closed
opened 2026-04-17 22:03:54 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4707
Author: @Bekacru
Created: 9/16/2025
Status: Merged
Merged: 9/16/2025
Merged by: @himself65

Base: canaryHead: fix/organization-cllient


📝 Commits (2)

  • ffbe3c2 fix(organization): decouple client and server permission checks
  • a08d031 chore: fix spelling

📊 Changes

3 files changed (+78 additions, -65 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/client.ts (+20 -2)
📝 packages/better-auth/src/plugins/organization/has-permission.ts (+5 -63)
packages/better-auth/src/plugins/organization/permission.ts (+53 -0)

📄 Description

Summary by cubic

Decoupled client and server permission checks by extracting shared logic to a new permission.ts and adding a client-only helper. This removes server context from client code and reduces duplication.

  • Refactors

    • Moved hasPermissionFn, types (PermissionExclusive, HasPermissionBaseInput), and cacheAllRoles into permission.ts.
    • Updated has-permission.ts to use shared logic; server behavior unchanged.
    • Added clientSideHasPermission in client.ts using hasPermissionFn and defaultRoles (no ctx or organizationId).
    • Cleaned up imports in client.ts to use defaultRoles and shared types.
  • Migration

    • If you imported clientSideHasPermission from has-permission.ts, import it from client.ts instead.

🔄 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/4707 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 9/16/2025 **Status:** ✅ Merged **Merged:** 9/16/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/organization-cllient` --- ### 📝 Commits (2) - [`ffbe3c2`](https://github.com/better-auth/better-auth/commit/ffbe3c23f18d182b4d858b8a254c7c6b3cbc0372) fix(organization): decouple client and server permission checks - [`a08d031`](https://github.com/better-auth/better-auth/commit/a08d03164083c8d8b4c1c7b760c02c863d3f68e8) chore: fix spelling ### 📊 Changes **3 files changed** (+78 additions, -65 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/client.ts` (+20 -2) 📝 `packages/better-auth/src/plugins/organization/has-permission.ts` (+5 -63) ➕ `packages/better-auth/src/plugins/organization/permission.ts` (+53 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Decoupled client and server permission checks by extracting shared logic to a new permission.ts and adding a client-only helper. This removes server context from client code and reduces duplication. - **Refactors** - Moved hasPermissionFn, types (PermissionExclusive, HasPermissionBaseInput), and cacheAllRoles into permission.ts. - Updated has-permission.ts to use shared logic; server behavior unchanged. - Added clientSideHasPermission in client.ts using hasPermissionFn and defaultRoles (no ctx or organizationId). - Cleaned up imports in client.ts to use defaultRoles and shared types. - **Migration** - If you imported clientSideHasPermission from has-permission.ts, import it from client.ts instead. <!-- 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 22:03:54 -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#31140