Commit eb57028b authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'improve-project-approvals-code-quality' into 'master'

Refactor project approvals param filter

See merge request gitlab-org/gitlab!26339
parents 7985d778 f54baa5f
...@@ -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
unless can?(current_user, :modify_approvers_rules, user_project)
params.delete(:disable_overriding_approvers_per_merge_request)
end 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