Count each permission only once in a user's permissionsCount - #6131
Closed
fraxachun wants to merge 1 commit into
Closed
Count each permission only once in a user's permissionsCount#6131fraxachun wants to merge 1 commit into
fraxachun wants to merge 1 commit into
Conversation
A permission that is granted both by rule and manually was counted twice, so the permissions count shown for a user in the admin could exceed the number of available permissions. Count distinct permissions instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JVwZJtKmfrQq2VZmPAB76j
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.
Problem
The
permissionsCountfield resolver for a user countedgetPermissions(user).length. A permission can be granted both by rule and manually, in which casegetPermissionsreturns it twice — so the permissions count shown for a user in the admin users list could be inflated and even exceed the number of available permissions (e.g. "19 of 18 permissions").Solution
Count distinct permissions by deduplicating on the permission name.
Adds a unit test covering a permission granted both by rule and manually.
Note
This is an independent bugfix, extracted from the user-permissions content-scope stack (#6114 → #6115 → #6116) so it can be reviewed and merged on its own. It does not depend on that stack.
🤖 Generated with Claude Code
Generated by Claude Code