Skip to content
Snippets Groups Projects
Unverified Commit 0bcfe9a0 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Dont allow set assignee, milestone or labels if user is guest

parent 5ff870a0
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -26,4 +26,18 @@ class IssuableBaseService < BaseService
issuable, issuable.project, current_user, branch_type,
old_branch, new_branch)
end
def filter_params
unless can?(current_user, :set_milestone, project)
params.delete(:milestone_id)
end
unless can?(current_user, :set_label, project)
params.delete(:label_ids)
end
unless can?(current_user, :set_assignee, project)
params.delete(:assignee_id)
end
end
end
module Issues
class CreateService < Issues::BaseService
def execute
filter_params
label_params = params[:label_ids]
issue = project.issues.new(params.except(:label_ids))
issue.author = current_user
Loading
Loading
Loading
Loading
@@ -17,6 +17,7 @@ module Issues
params[:assignee_id] = "" if params[:assignee_id] == IssuableFinder::NONE
params[:milestone_id] = "" if params[:milestone_id] == IssuableFinder::NONE
 
filter_params
old_labels = issue.labels.to_a
 
if params.present? && issue.update_attributes(params.except(:state_event,
Loading
Loading
module MergeRequests
class CreateService < MergeRequests::BaseService
def execute
filter_params
label_params = params[:label_ids]
merge_request = MergeRequest.new(params.except(:label_ids))
merge_request.source_project = project
Loading
Loading
Loading
Loading
@@ -27,6 +27,7 @@ module MergeRequests
params[:assignee_id] = "" if params[:assignee_id] == IssuableFinder::NONE
params[:milestone_id] = "" if params[:milestone_id] == IssuableFinder::NONE
 
filter_params
old_labels = merge_request.labels.to_a
 
if params.present? && merge_request.update_attributes(
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment