Repository navigation
Keep the system flag of a customer group out of the edit form - #1085
Merged
Merged
Conversation
The form posted IsSystem back through a hidden input and the profile mapped it onto the group. Posting false took the protection off a system group, after which its system name could be changed, the group deactivated or deleted; posting true made a new group undeletable. IsSystem is now never bound nor mapped; the installer seeds it.
The API profile mapped IsSystem from the request onto the stored group, and Patch checked the flag after applying the patch, so the request could clear it. IsSystem is now ignored when mapping a DTO onto a group, and Patch refuses a system group before applying the patch.
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.
Type: bugfix
Issue
The customer group edit form posted
IsSystemback through a hidden input, andCustomerGroupProfilemapped it onto the stored group.CustomerGroupValidatoronly protectsSystemNameandActivewhen the stored group is a system group, andDeleteCustomerGrouprefuses only stored system groups.So a tampered POST with
IsSystem=falseon a system group (Administrators, Registered, Guests, …) passed validation and saved the group as non-system. A second POST could then rename its system name, deactivate it or delete it. PostingIsSystem=trueon create made a new group undeletable.To reproduce: open Admin → Customers → Customer groups → Administrators, change the hidden
IsSysteminput tofalsein the browser dev tools and save; the list now shows the group without the system check mark.Solution
CustomerGroupModel.IsSystemis[BindNever]and ignored in the model → entity map. Only the installer sets it.IsSystemis ignored when aCustomerGroupDtois mapped onto a group, so POST cannot create a system group and PUT/PATCH cannot clear the flag. PATCH now refuses a system group before applying the patch (it used to check the patched value).Breaking changes
None.
IsSystemwas never editable in the UI; anything that posted it can no longer change it.Testing
<input name="IsSystem" value="false">to the form: after saving, the list still shows Administrators as a system group, and changing its system name is still refused.IsSystem=truefield: it is created as a non-system group and can be deleted.replace /IsSystem falsereturns 400 and the group stays a system group;POSTwithIsSystem: truecreates a non-system group.dotnet test src/Tests/Grand.Mapping.Tests --filter "CustomerMappingTests|ApiMappingTests"passes.