[PR #4647] [MERGED] chore(org): dynamic ac improvements #31105

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4647
Author: @ping-maxwell
Created: 9/14/2025
Status: Merged
Merged: 9/15/2025
Merged by: @himself65

Base: canaryHead: chore/organization/minor-dynamic-ac-improvements


📝 Commits (5)

  • a26688f chore(org): minor improvements
  • d07234e chore: cleanup
  • 8317ecf add: tests
  • f2c22b2 fix: missing error messages
  • 67b9c71 Merge branch 'canary' into chore/organization/minor-dynamic-ac-improvements

📊 Changes

3 files changed (+146 additions, -80 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/error-codes.ts (+14 -0)
📝 packages/better-auth/src/plugins/organization/routes/crud-access-control.test.ts (+73 -41)
📝 packages/better-auth/src/plugins/organization/routes/crud-access-control.ts (+59 -39)

📄 Description

  • Moved error messages to the ORGANIZATION_ERROR_MESSAGE object.
  • Added new tests
  • Other tiny changes

Summary by cubic

Standardized Dynamic Access Control errors in the organization plugin by moving messages to ORGANIZATION_ERROR_CODES and applying them across role CRUD endpoints. This makes API responses consistent and cleans up a few types and utilities.

  • Refactors
    • Replaced hardcoded strings with ORGANIZATION_ERROR_CODES across create/read/update/delete/list/get role routes.
    • Mapped permission failures to specific action-based messages.
    • Added codes: MISSING_AC_INSTANCE, INVALID_RESOURCE, ROLE_NAME_IS_ALREADY_TAKEN, TOO_MANY_ROLES, CANNOT_DELETE_A_PRE_DEFINED_ROLE, ROLE_NOT_FOUND, ORGANIZATION_NOT_FOUND.
    • Simplified normalizeRoleName(role: string) and updated callers.
    • Tightened AdditionalFields typing in helper utilities.

🔄 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/4647 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 9/14/2025 **Status:** ✅ Merged **Merged:** 9/15/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `chore/organization/minor-dynamic-ac-improvements` --- ### 📝 Commits (5) - [`a26688f`](https://github.com/better-auth/better-auth/commit/a26688fd2d3b18e591592659a9f5251836506b9c) chore(org): minor improvements - [`d07234e`](https://github.com/better-auth/better-auth/commit/d07234ee5f7386521e184979480ab1ef53165f16) chore: cleanup - [`8317ecf`](https://github.com/better-auth/better-auth/commit/8317ecf803b79029a4e6353a46b2954c78239e2b) add: tests - [`f2c22b2`](https://github.com/better-auth/better-auth/commit/f2c22b2a5bbc933138157edac8c767b821044543) fix: missing error messages - [`67b9c71`](https://github.com/better-auth/better-auth/commit/67b9c7130bcf9afb0064d3224f5c067cad3b826a) Merge branch 'canary' into chore/organization/minor-dynamic-ac-improvements ### 📊 Changes **3 files changed** (+146 additions, -80 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/error-codes.ts` (+14 -0) 📝 `packages/better-auth/src/plugins/organization/routes/crud-access-control.test.ts` (+73 -41) 📝 `packages/better-auth/src/plugins/organization/routes/crud-access-control.ts` (+59 -39) </details> ### 📄 Description * Moved error messages to the `ORGANIZATION_ERROR_MESSAGE` object. * Added new tests * Other tiny changes <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Standardized Dynamic Access Control errors in the organization plugin by moving messages to ORGANIZATION_ERROR_CODES and applying them across role CRUD endpoints. This makes API responses consistent and cleans up a few types and utilities. - **Refactors** - Replaced hardcoded strings with ORGANIZATION_ERROR_CODES across create/read/update/delete/list/get role routes. - Mapped permission failures to specific action-based messages. - Added codes: MISSING_AC_INSTANCE, INVALID_RESOURCE, ROLE_NAME_IS_ALREADY_TAKEN, TOO_MANY_ROLES, CANNOT_DELETE_A_PRE_DEFINED_ROLE, ROLE_NOT_FOUND, ORGANIZATION_NOT_FOUND. - Simplified normalizeRoleName(role: string) and updated callers. - Tightened AdditionalFields typing in helper utilities. <!-- 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:02:15 -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#31105