summaryrefslogtreecommitdiff
path: root/app/services/groups
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-09-01 18:00:46 -0700
committerMichael Kozono <mkozono@gmail.com>2017-09-06 12:07:20 -0700
commit6c57734677746aa0e6695aa75990a85a7f95b50d (patch)
tree792a4a0a0a8856ca4702c4464862b53d4bd9461b /app/services/groups
parent1cc7f4a45d9e9fdf1943eb92d3cd2071ba497337 (diff)
downloadgitlab-ce-6c57734677746aa0e6695aa75990a85a7f95b50d.tar.gz
Enforce share_with_group_lock rules
…in Groups::UpdateService instead of only in the browser.
Diffstat (limited to 'app/services/groups')
-rw-r--r--app/services/groups/update_service.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/app/services/groups/update_service.rb b/app/services/groups/update_service.rb
index 1d65c76d282..45716c63cfc 100644
--- a/app/services/groups/update_service.rb
+++ b/app/services/groups/update_service.rb
@@ -10,10 +10,12 @@ module Groups
Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility)
deny_visibility_level(group, new_visibility)
- return group
+ return false
end
end
+ return false unless valid_share_with_group_lock_change?
+
group.assign_attributes(params)
begin
@@ -30,5 +32,19 @@ module Groups
def reject_parent_id!
params.except!(:parent_id)
end
+
+ def valid_share_with_group_lock_change?
+ return true unless changing_share_with_group_lock?
+ return true if can?(current_user, :change_share_with_group_lock, group)
+
+ group.errors.add(:share_with_group_lock, 'cannot be disabled when the parent group Share lock is enabled, except by the owner of the parent group')
+ false
+ end
+
+ def changing_share_with_group_lock?
+ return false if params[:share_with_group_lock].nil?
+
+ params[:share_with_group_lock] != group.share_with_group_lock
+ end
end
end