[PM-38923] feat: Add v2 UpdateOrganizationUser command with role-escalation validation#7919
Draft
jrmccannon wants to merge 4 commits into
Conversation
…lation validation Refactor the OrganizationUsersController.Put flow into a v2 command + validator (returning CommandResult / ValidationResult<T>), gated behind the pm-28365-change-member-email-no-mp feature flag. The validator ports v1's request validation and adds the escalating-role guard by delegating to the shared IOrganizationUserValidationService.CanManage rules (PM-38927), while preserving v1's specific error messages. The controller supplies the acting user's membership (role + permissions) as a plain field so Core stays free of ICurrentContext.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## jmccannon/ac/pm-38927-org-user-role-validation #7919 +/- ##
==================================================================================
+ Coverage 61.36% 61.42% +0.05%
==================================================================================
Files 2238 2242 +4
Lines 98563 98793 +230
Branches 8914 8948 +34
==================================================================================
+ Hits 60482 60682 +200
- Misses 35944 35962 +18
- Partials 2137 2149 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… UpdateOrganizationUser Pass the API-loaded collections into the v2 validation request so the validator validates existence without re-querying. The validator now rejects default user collections with a new CannotAssignDefaultCollection error instead of silently filtering them, and the controller excludes current-access defaults from the preserved read-only set.
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.
🎟️ Tracking
PM-38923 (epic PM-28365 — "Manual single-email change for members without passwords")
Note
This PR is based on #7876 (PM-38927) and targets that branch, since it builds on the new
IOrganizationUserValidationService. It should be re-based ontomainonce #7876 merges. The diff will shrink to just the commits below once the base lands.📔 Objective
Refactors
OrganizationUsersController.Putand the v1UpdateOrganizationUserCommandinto a v2 command + validator (returningCommandResult/ValidationResult<T>), mirroring the RevokeUser v2 pattern. The v2 path is gated behind thepm-28365-change-member-email-no-mpfeature flag and stays off by default.Key points:
IOrganizationUserValidationService.CanManagerules from [PM-38927] - Extract Organziation User Role Validation #7876, checking both the member's current role and the requested role so an existing higher-ranked member can't be modified from below. v1's specific error messages are preserved by mapping the denial (OnlyOwnersCanManageOwners/CustomUsersCannotManageAdminsOrOwners).ICurrentContext/ClaimsPrincipal; the controller passes the acting user's membership (role + permissions) and theIActingUseras plain inputs. Collection resource authorization (ModifyUserAccess) stays in the controller.Putcollection-auth unit tests to mock the bulkModifyUserAccessauthorization call.Test coverage
Putcollection-auth tests (42/42 in the two controller test classes).📸 Screenshots