improvement(perms): followup to org scoping of permission groups#5039
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview The Admin DELETE access-control adds an explicit Reviewed by Cursor Bugbot for commit 3c4234c. Configure here. |
Greptile SummaryThis PR fixes permission-group admin gating to use the workspace's owning organization rather than the caller's active organization, so external members (users who belong to a workspace via a different org) are no longer incorrectly treated as admins of that workspace's org.
Confidence Score: 5/5Safe to merge — the fix correctly moves org-admin resolution to the server, all query cascades are properly gated, and every response path in the API route returns the new fields. The core logic change is straightforward: the API route now derives both organizationId and isOrgAdmin from the workspace record rather than the session's active org. All four return sites in the route consistently include the new fields, the Zod contract is updated to match, and the component drops the now-redundant client-side role computation without leaving orphaned state. The isLoading chain correctly waits for entitlement before cascading to groups, and the admin DELETE route gains a proper null guard instead of a non-null assertion. No files require special attention; the two-round-trip latency for org admins (userPermissionConfig must resolve before permission groups can be fetched) is intentional and well-handled by the isLoading guard. Important Files Changed
Sequence DiagramsequenceDiagram
participant C as AccessControl (client)
participant UPC as /api/permission-groups/user
participant PG as /api/organizations/[id]/permission-groups
participant Roster as org roster
participant DB as Database
C->>UPC: "GET ?workspaceId=X"
UPC->>DB: checkWorkspaceAccess(workspaceId, userId)
DB-->>UPC: workspace (incl. organizationId)
alt no organizationId
UPC-->>C: "{isOrgAdmin: false, organizationId: null, entitled: false}"
else has organizationId
UPC->>DB: isOrganizationAdminOrOwner(userId, orgId)
DB-->>UPC: isOrgAdmin
UPC->>DB: isOrganizationOnEnterprisePlan(orgId)
DB-->>UPC: entitled
UPC-->>C: "{isOrgAdmin, organizationId, entitled, ...}"
end
C->>C: "organizationId = userPermissionConfig.organizationId"
C->>C: "currentUserIsOrgAdmin = userPermissionConfig.isOrgAdmin"
alt "currentUserIsOrgAdmin == true"
C->>PG: GET (fetch permission groups)
PG-->>C: permissionGroups[]
C->>Roster: GET (fetch org roster)
Roster-->>C: roster[]
end
Reviews (1): Last reviewed commit: "followup" | Re-trigger Greptile |
Summary
Followup to #5035
Type of Change
Testing
Tested manually
Checklist