Use guard clause to check ability to share project
This commit is contained in:
parent
d177abb32b
commit
66b6d82a3e
1 changed files with 4 additions and 7 deletions
|
@ -8,14 +8,11 @@ class Projects::GroupLinksController < Projects::ApplicationController
|
|||
|
||||
def create
|
||||
group = Group.find(params[:link_group_id])
|
||||
return render_404 unless can?(current_user, :read_group, group)
|
||||
|
||||
if can?(current_user, :read_group, group)
|
||||
project.project_group_links.create(
|
||||
group: group, group_access: params[:link_group_access]
|
||||
)
|
||||
else
|
||||
return render_404
|
||||
end
|
||||
project.project_group_links.create(
|
||||
group: group, group_access: params[:link_group_access]
|
||||
)
|
||||
|
||||
redirect_to namespace_project_group_links_path(project.namespace, project)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue