fix(groups): enforce invite role hierarchy - #604
Merged
junhoyeo merged 1 commit intoMay 27, 2026
Conversation
Validation * Validation tier: Tier 2 - narrow runtime change, route-level permission check for group invite creation. * bun x vitest run __tests__/api/groupInviteRoute.test.ts: PASS after fix; RED before fix failed as expected with admin-created admin invite returning 201 instead of 403. * bun x vitest run __tests__/api/groupInviteRoute.test.ts __tests__/api/groupInviteJoinRoute.test.ts __tests__/lib/groupInvites.test.ts __tests__/lib/groupHelpers.test.ts: PASS, 14 tests. * bun x vitest run __tests__/api/group*.test.ts __tests__/lib/group*.test.ts: PASS, 20 tests. * bun x eslint __tests__/api/groupInviteRoute.test.ts 'src/app/api/groups/[slug]/invite/route.ts': PASS. * git diff --check: PASS. * git diff --cached --check: PASS. * Ledger: not applicable - not required for selected validation tier/change family. * Version: not applicable - not required for selected validation tier/change family. * Not required: full frontend lint/typecheck for this targeted route change; when probed, bun run lint and bun x tsc -p tsconfig.json --noEmit fail on unrelated existing frontend issues outside this diff. Rollback * git revert HEAD
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Owner
|
@IvGolovach this has been merged to v3.0.0: https://github.com/junhoyeo/tokscale/releases/tag/v3.0.0 thanks for the contribution! |
leecoder
pushed a commit
to leecoder/tokscale
that referenced
this pull request
May 29, 2026
Validation * Validation tier: Tier 2 - narrow runtime change, route-level permission check for group invite creation. * bun x vitest run __tests__/api/groupInviteRoute.test.ts: PASS after fix; RED before fix failed as expected with admin-created admin invite returning 201 instead of 403. * bun x vitest run __tests__/api/groupInviteRoute.test.ts __tests__/api/groupInviteJoinRoute.test.ts __tests__/lib/groupInvites.test.ts __tests__/lib/groupHelpers.test.ts: PASS, 14 tests. * bun x vitest run __tests__/api/group*.test.ts __tests__/lib/group*.test.ts: PASS, 20 tests. * bun x eslint __tests__/api/groupInviteRoute.test.ts 'src/app/api/groups/[slug]/invite/route.ts': PASS. * git diff --check: PASS. * git diff --cached --check: PASS. * Ledger: not applicable - not required for selected validation tier/change family. * Version: not applicable - not required for selected validation tier/change family. * Not required: full frontend lint/typecheck for this targeted route change; when probed, bun run lint and bun x tsc -p tsconfig.json --noEmit fail on unrelated existing frontend issues outside this diff. Rollback * git revert HEAD
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
This PR enforces the existing group role hierarchy when creating group invites. Admins can still invite regular members, and owners can still invite admins, but invites can no longer bypass the direct role-management restrictions.
Why
Direct member role changes already require the actor to outrank the target role. The invite route did not apply the same rule before creating an invite, so an admin could create an
admininvite and grant peer-level permissions through the join flow.Diff Scope
canManageGroupRoleinPOST /api/groups/[slug]/invitebefore creating an invite.Branch Integrity
junhoyeo/tokscale:main8e73312f05f603d5184d36059e4ce2604322d492IvGolovach:codex/groups-invite-role-hierarchyae01b4648e7746bc0fe25d04cb00ae473324e46a0 behind / 1 aheadCommit Integrity
ae01b4648e7746bc0fe25d04cb00ae473324e46a fix(groups): enforce invite role hierarchyDiff Hygiene
git diff --check origin/main...HEAD: PASS, no outputValidation
Validation mode: Mode 2 — narrow frontend route permission change.
bun x vitest run __tests__/api/groupInviteRoute.test.ts: PASSbun x vitest run __tests__/api/groupInviteRoute.test.ts __tests__/api/groupInviteJoinRoute.test.ts __tests__/lib/groupInvites.test.ts __tests__/lib/groupHelpers.test.ts: PASS, 14 testsbun x vitest run __tests__/api/group*.test.ts __tests__/lib/group*.test.ts: PASS, 20 testsbun x eslint __tests__/api/groupInviteRoute.test.ts 'src/app/api/groups/[slug]/invite/route.ts': PASSgit diff --check origin/main...HEAD: PASSNot used as proof: full frontend lint/typecheck currently report unrelated existing issues outside this diff, so this PR relies on targeted route coverage and targeted ESLint.
CI Context
Pending — required remote checks will run after the PR is opened.
Runtime Safety
This only tightens an existing permission check on invite creation. It does not change invite token format, invite acceptance persistence, group membership schema, or cache invalidation behavior. No invariant regression introduced.
Rollback Plan
Rollback: revert this PR.
DB downgrade: not applicable.
Data repair: not applicable.
Operational caveats: reverting would restore the invite-based role escalation path for group admins.
Known Residual Risks
None known for the scoped permission fix.