Use guard clause to check ability to share project

This commit is contained in:
Grzegorz Bizon 2016-04-18 12:00:47 +02:00
parent d177abb32b
commit 66b6d82a3e
1 changed files with 4 additions and 7 deletions

View File

@ -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