[PR #5439] fix(organization): allow owners/admins to view invitations #31611

Open
opened 2026-04-17 22:30:20 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5439
Author: @ahmed-abdat
Created: 10/20/2025
Status: 🔄 Open

Base: mainHead: fix/org-owner-admin-get-invitation-4272


📝 Commits (1)

  • 8eb1952 fix(organization): allow owners/admins to view invitations

📊 Changes

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

View changed files

📝 packages/better-auth/src/plugins/organization/organization.test.ts (+152 -0)
📝 packages/better-auth/src/plugins/organization/routes/crud-invites.ts (+33 -4)

📄 Description

Fixes #4272

Problem

The getInvitation endpoint only allowed invitation recipients to view invitations. Organization owners and admins should also be able to view invitations in their organization for management purposes.

Solution

Added permission check using hasPermission with invitation: ["cancel"] permission, which is granted to owners and admins by default. This follows the same pattern used in the cancelInvitation endpoint.

Tests

  • Recipients can view their invitations
  • Owners can view any invitation in their org
  • Admins can view any invitation in their org
  • Regular members cannot view invitations they're not recipient of
  • All organization tests pass
  • Biome lint check passes

Summary by cubic

Allow org owners and admins to view invitations via getInvitation, matching cancelInvitation permissions. Regular members still can’t view others’ invites.

  • Bug Fixes
    • Added hasPermission check (invitation: ["cancel"]) for non-recipient access; owners/admins allowed by default.
    • Return 403 for non-members and members without this permission, with YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION.
    • Added tests for recipient, owner, admin, and regular member cases.

🔄 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/5439 **Author:** [@ahmed-abdat](https://github.com/ahmed-abdat) **Created:** 10/20/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/org-owner-admin-get-invitation-4272` --- ### 📝 Commits (1) - [`8eb1952`](https://github.com/better-auth/better-auth/commit/8eb1952a7c921901e5403025744a0ad0e0b6612a) fix(organization): allow owners/admins to view invitations ### 📊 Changes **2 files changed** (+185 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/organization.test.ts` (+152 -0) 📝 `packages/better-auth/src/plugins/organization/routes/crud-invites.ts` (+33 -4) </details> ### 📄 Description Fixes #4272 ### Problem The `getInvitation` endpoint only allowed invitation recipients to view invitations. Organization owners and admins should also be able to view invitations in their organization for management purposes. ### Solution Added permission check using `hasPermission` with `invitation: ["cancel"]` permission, which is granted to owners and admins by default. This follows the same pattern used in the `cancelInvitation` endpoint. ### Tests - [x] Recipients can view their invitations - [x] Owners can view any invitation in their org - [x] Admins can view any invitation in their org - [x] Regular members cannot view invitations they're not recipient of - [x] All organization tests pass - [x] Biome lint check passes <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Allow org owners and admins to view invitations via getInvitation, matching cancelInvitation permissions. Regular members still can’t view others’ invites. - **Bug Fixes** - Added hasPermission check (invitation: ["cancel"]) for non-recipient access; owners/admins allowed by default. - Return 403 for non-members and members without this permission, with YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION. - Added tests for recipient, owner, admin, and regular member cases. <!-- 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:30:20 -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#31611