Skip to content

Keep the system flag of a customer group out of the edit form - #1085

Merged
KrzysztofPajak merged 2 commits into
developfrom
fix/customer-group-is-system
Nov 23, 2026
Merged

KrzysztofPajak merged 2 commits into
developfrom
fix/customer-group-is-system

Conversation

@KrzysztofPajak

@KrzysztofPajak KrzysztofPajak commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Type: bugfix

Issue

The customer group edit form posted IsSystem back through a hidden input, and CustomerGroupProfile mapped it onto the stored group. CustomerGroupValidator only protects SystemName and Active when the stored group is a system group, and DeleteCustomerGroup refuses only stored system groups.

So a tampered POST with IsSystem=false on 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. Posting IsSystem=true on create made a new group undeletable.

To reproduce: open Admin → Customers → Customer groups → Administrators, change the hidden IsSystem input to false in the browser dev tools and save; the list now shows the group without the system check mark.

Solution

  • CustomerGroupModel.IsSystem is [BindNever] and ignored in the model → entity map. Only the installer sets it.
  • The hidden input is gone; the view still shows the value as a fact.
  • When the edit form is shown again after a validation error, the flag comes from the stored group.
  • The API does the same: IsSystem is ignored when a CustomerGroupDto is 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. IsSystem was never editable in the UI; anything that posted it can no longer change it.

Testing

  1. Admin → Customers → Customer groups → Administrators. Change something harmless (e.g. Free shipping) and save: the group stays a system group.
  2. Repeat with the browser dev tools adding <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.
  3. Create a new group with an added IsSystem=true field: it is created as a non-system group and can be deleted.
  4. API: PATCH the Administrators group with replace /IsSystem false returns 400 and the group stays a system group; POST with IsSystem: true creates a non-system group.
  5. dotnet test src/Tests/Grand.Mapping.Tests --filter "CustomerMappingTests|ApiMappingTests" passes.

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.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 18:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.
@KrzysztofPajak
KrzysztofPajak merged commit 3f89764 into develop Nov 23, 2026
9 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the fix/customer-group-is-system branch November 25, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants