diff options
Diffstat (limited to 'app/services/namespace_settings')
-rw-r--r-- | app/services/namespace_settings/update_service.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/services/namespace_settings/update_service.rb b/app/services/namespace_settings/update_service.rb index de54eb87cc0..80f15f7cc22 100644 --- a/app/services/namespace_settings/update_service.rb +++ b/app/services/namespace_settings/update_service.rb @@ -14,6 +14,7 @@ module NamespaceSettings def execute validate_resource_access_token_creation_allowed_param + validate_prevent_sharing_groups_outside_hierarchy_param if group.namespace_settings group.namespace_settings.attributes = settings_params @@ -32,6 +33,15 @@ module NamespaceSettings group.namespace_settings.errors.add(:resource_access_token_creation_allowed, _('can only be changed by a group admin.')) end end + + def validate_prevent_sharing_groups_outside_hierarchy_param + return if settings_params[:prevent_sharing_groups_outside_hierarchy].nil? + + unless can?(current_user, :change_prevent_sharing_groups_outside_hierarchy, group) + settings_params.delete(:prevent_sharing_groups_outside_hierarchy) + group.namespace_settings.errors.add(:prevent_sharing_groups_outside_hierarchy, _('can only be changed by a group admin.')) + end + end end end |