Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMałgorzata Ksionek <meksionek@gmail.com>2019-02-12 15:29:47 +0300
committerMałgorzata Ksionek <meksionek@gmail.com>2019-02-20 16:13:36 +0300
commitd2c83f40498fc76388779cd3f42f9c6ea6fed555 (patch)
tree834048d414a6bfd96a9c31bb86183e74f62098ef /lib
parent902e4f63d6fffe782757bcc3c6c0963e02250eb1 (diff)
Change policy regarding group visibility
Diffstat (limited to 'lib')
-rw-r--r--lib/api/projects.rb15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 6a93ef9f3ad..a7b4dc06832 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -436,27 +436,24 @@ module API
end
params do
requires :group_id, type: Integer, desc: 'The ID of a group'
- requires :group_access, type: Integer, values: Gitlab::Access.values, desc: 'The group access level'
+ requires :group_access, type: Integer, values: Gitlab::Access.values, as: :link_group_access, desc: 'The group access level'
optional :expires_at, type: Date, desc: 'Share expiration date'
end
post ":id/share" do
authorize! :admin_project, user_project
group = Group.find_by_id(params[:group_id])
- unless group && can?(current_user, :read_group, group)
- not_found!('Group')
- end
-
unless user_project.allowed_to_share_with_group?
break render_api_error!("The project sharing with group is disabled", 400)
end
- link = user_project.project_group_links.new(declared_params(include_missing: false))
+ result = ::Projects::GroupLinks::CreateService.new(user_project, current_user, declared_params(include_missing: false))
+ .execute(group)
- if link.save
- present link, with: Entities::ProjectGroupLink
+ if result[:status] == :success
+ present result[:link], with: Entities::ProjectGroupLink
else
- render_api_error!(link.errors.full_messages.first, 409)
+ render_api_error!(result[:message], result[:http_status])
end
end