fix: align organization role display and invite authorization with membership owner role#1642
Open
DaveMiscampbell wants to merge 4 commits intoCapSoftware:mainfrom
Open
Conversation
Contributor
Additional Comments (1)
In the drift scenario this PR addresses — where a user's membership Consider applying the same membership-role check to these actions:
Prompt To Fix With AIThis is a comment left during a code review.
Path: apps/web/app/(org)/dashboard/settings/organization/components/MembersCard.tsx
Line: 52
Comment:
The "Remove member" and "Delete Invite" actions still gate on `isOwner` (derived from `organizations.ownerId`), while the "Invite users" button now gates on `canInviteUsers` (derived from `organizationMembers.role`).
In the drift scenario this PR addresses — where a user's membership `role` is `"owner"` but they are not the `ownerId` — they can invite users but cannot remove members or delete pending invites. This leaves the inconsistency only partially fixed.
Consider applying the same membership-role check to these actions:
- `handleDeleteInvite` guard (line 52)
- Remove-member button (lines 227, 239)
- Delete-invite button (lines 262, 268)
How can I resolve this? If you propose a fix, please make it concise. |
…ole display and invite authorization
81adcc6 to
db2c812
Compare
apps/web/app/(org)/dashboard/_components/Navbar/MemberAvatars.tsx
Outdated
Show resolved
Hide resolved
apps/web/app/(org)/dashboard/settings/organization/billing/page.tsx
Outdated
Show resolved
Hide resolved
apps/web/app/(org)/dashboard/settings/organization/components/MembersCard.tsx
Outdated
Show resolved
Hide resolved
…rization for member management
Author
|
Addressed review feedback in two follow-up commits:
I also resolved all outdated review threads. |
Author
|
Resolves #1641 |
…xistence queries in owner checks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
organization_members.role = ownerinsendOrganizationInvitesorganization_members.roleinstead of inferring ownership fromorganizations.ownerIdownerIdand membership data drift:Why
Ownership currently exists in two sources (
organizations.ownerIdandorganization_members.role). In self-hosted or manually migrated databases these can drift, causing inconsistent behavior:Memberin the members tableownerIdThis PR makes invite permissions and role rendering consistent with membership role ownership.
Validation
pnpm exec biome check --writeon touched org files (passes for edited files except a pre-existing lint inMemberAvatarsunrelated to this change)pnpm typecheckremains failing repo-wide on existing test/type issues, but no errors were emitted for the touched files in filtered outputFiles Changed
apps/web/actions/organization/send-invites.tsapps/web/app/(org)/dashboard/settings/organization/components/MembersCard.tsxapps/web/app/(org)/dashboard/settings/organization/billing/page.tsxapps/web/app/(org)/dashboard/_components/Navbar/MemberAvatars.tsx