Skip to content

Conversation

@AndyButland
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

Fixes #19992

Description

We currently have restrictions such that you can't create or invite a user without specifying at least one user group.

This aligns the behaviour for updates to prevent removing all groups (and also aligns with what we had in 13, as the linked issue points out).

Testing

For a user, verify that you can't remove all user groups from them. If you attempt to, the following response in the UI should be seen and the update rejected.

image

Copilot AI review requested due to automatic review settings August 26, 2025 08:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR prevents users from having all their user groups removed during updates, maintaining consistency with user creation/invitation validation and aligning with Umbraco 13 behavior.

  • Adds validation to reject user updates that would result in zero user groups
  • Updates error message to be more generic for both create and update scenarios
  • Includes integration test coverage for the new validation

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Umbraco.Core/Services/UserService.cs Adds validation to prevent updating a user to have no groups
src/Umbraco.Cms.Api.Management/Controllers/User/UserOrCurrentUserControllerBase.cs Updates error message to cover both create and update scenarios
tests/Umbraco.Tests.Integration/Umbraco.Core/Services/UserServiceCrudTests.Update.cs Adds test to verify users cannot be updated to have no groups

# Conflicts:
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/User.spec.ts
@nikolajlauridsen nikolajlauridsen enabled auto-merge (squash) August 27, 2025 11:34
Copy link
Contributor

@nikolajlauridsen nikolajlauridsen left a comment

Choose a reason for hiding this comment

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

Looks good, tests good 👍

@nikolajlauridsen nikolajlauridsen merged commit cbb1eae into main Aug 27, 2025
24 of 25 checks passed
@nikolajlauridsen nikolajlauridsen deleted the v16/bugfix/prevent-remove-all-groups-from-user branch August 27, 2025 11:38
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.

Able to remove all user groups from a user

3 participants