[PR #3329] [CLOSED] feat(organization): support organizationSlug in hasPermission #13006

Closed
opened 2026-04-13 08:41:58 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3329
Author: @tinkerer-shubh
Created: 7/10/2025
Status: Closed

Base: mainHead: feat/org-slug-permission


📝 Commits (2)

  • 4e4da4e feat(organization): support organizationSlug in hasPermission
  • 36fb98a Merge branch 'main' into feat/org-slug-permission

📊 Changes

2 files changed (+105 additions, -4 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/adapter.ts (+48 -0)
📝 packages/better-auth/src/plugins/organization/organization.ts (+57 -4)

📄 Description

closes https://github.com/better-auth/better-auth/issues/3309

The pull request introduces the following changes:

  1. In packages/better-auth/src/plugins/organization/adapter.ts:

    • Adds a new method findMemberByOrgSlug to fetch a member based on the user's ID and the organization's slug. This method optimizes the lookup by resolving the organization via its slug and then finding the member directly, rather than loading all members.
  2. In packages/better-auth/src/plugins/organization/organization.ts:

    • Updates the API to accept an optional organizationSlug in addition to organizationId.
    • Refactors the logic in the permission check route to:
      • Prefer using organizationSlug if provided, falling back to organizationId or the active organization ID.
      • Use the new findMemberByOrgSlug method for slug-based lookups.
      • Return a more precise error if the organization is not found or if the user is not a member.
    • Handles both slug-based and ID-based organization member lookups.
    • Ensures the returned member role is used in the permission check.

🔄 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/3329 **Author:** [@tinkerer-shubh](https://github.com/tinkerer-shubh) **Created:** 7/10/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/org-slug-permission` --- ### 📝 Commits (2) - [`4e4da4e`](https://github.com/better-auth/better-auth/commit/4e4da4e39d222d6601f286a10d12489cfb721613) feat(organization): support organizationSlug in hasPermission - [`36fb98a`](https://github.com/better-auth/better-auth/commit/36fb98a9f4983507ad00061901751124eabd3a60) Merge branch 'main' into feat/org-slug-permission ### 📊 Changes **2 files changed** (+105 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/adapter.ts` (+48 -0) 📝 `packages/better-auth/src/plugins/organization/organization.ts` (+57 -4) </details> ### 📄 Description closes https://github.com/better-auth/better-auth/issues/3309 The pull request introduces the following changes: 1. **In `packages/better-auth/src/plugins/organization/adapter.ts`:** - Adds a new method `findMemberByOrgSlug` to fetch a member based on the user's ID and the organization's slug. This method optimizes the lookup by resolving the organization via its slug and then finding the member directly, rather than loading all members. 2. **In `packages/better-auth/src/plugins/organization/organization.ts`:** - Updates the API to accept an optional `organizationSlug` in addition to `organizationId`. - Refactors the logic in the permission check route to: - Prefer using `organizationSlug` if provided, falling back to `organizationId` or the active organization ID. - Use the new `findMemberByOrgSlug` method for slug-based lookups. - Return a more precise error if the organization is not found or if the user is not a member. - Handles both slug-based and ID-based organization member lookups. - Ensures the returned member role is used in the permission check. --- <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-13 08:41:58 -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#13006