FIX: Users should be able to remove their primary group

This fix allows a user to remove their currently assigned primary group
if the Site Setting `user selected primary groups` is enabled.

Before this fix, if a user selected "none" for their primary group it
would silently fail and never be updated.
This commit is contained in:
Blake Erickson
2020-01-17 15:43:54 -07:00
parent 3fc589f875
commit 75069ff179
2 changed files with 24 additions and 0 deletions

View File

@@ -89,6 +89,10 @@ class UserUpdater
guardian.can_use_primary_group?(user, attributes[:primary_group_id])
user.primary_group_id = attributes[:primary_group_id]
elsif SiteSetting.user_selected_primary_groups &&
!attributes[:primary_group_id].present?
user.primary_group_id = nil
end
CATEGORY_IDS.each do |attribute, level|