Commit f54baa5f authored by Giorgenes Gelatti's avatar Giorgenes Gelatti

Refactor project approvals param filter

parent 2b5d9cb7
...@@ -8,18 +8,16 @@ module API ...@@ -8,18 +8,16 @@ module API
ARRAY_COERCION_LAMBDA = ->(val) { val.empty? ? [] : Array.wrap(val) } ARRAY_COERCION_LAMBDA = ->(val) { val.empty? ? [] : Array.wrap(val) }
helpers do helpers do
def filter_params(params) def filter_forbidden_param!(permission, param)
unless can?(current_user, :modify_merge_request_committer_setting, user_project) unless can?(current_user, permission, user_project)
params.delete(:merge_requests_disable_committers_approval) params.delete(param)
end end
unless can?(current_user, :modify_approvers_rules, user_project)
params.delete(:disable_overriding_approvers_per_merge_request)
end end
unless can?(current_user, :modify_merge_request_author_setting, user_project) def filter_params(params)
params.delete(:merge_requests_author_approval) filter_forbidden_param!(:modify_merge_request_committer_setting, :merge_requests_disable_committers_approval)
end filter_forbidden_param!(:modify_approvers_rules, :disable_overriding_approvers_per_merge_request)
filter_forbidden_param!(:modify_merge_request_author_setting, :merge_requests_author_approval)
params params
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment