Fix groups api: differ between users and admin
This commit is contained in:
parent
fc0c692870
commit
149ccd5d91
2 changed files with 50 additions and 44 deletions
|
@ -33,7 +33,7 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
class Group < Grape::Entity
|
class Group < Grape::Entity
|
||||||
expose :id, :name, :path, :name, :owner_id, :type
|
expose :id, :name, :path, :owner_id
|
||||||
end
|
end
|
||||||
|
|
||||||
class GroupDetail < Grape::Entity
|
class GroupDetail < Grape::Entity
|
||||||
|
|
|
@ -9,9 +9,12 @@ module Gitlab
|
||||||
# Example Request:
|
# Example Request:
|
||||||
# GET /groups
|
# GET /groups
|
||||||
get do
|
get do
|
||||||
|
if current_user.admin
|
||||||
@groups = paginate Group
|
@groups = paginate Group
|
||||||
|
else
|
||||||
|
@groups = paginate current_user.groups
|
||||||
|
end
|
||||||
present @groups, with: Entities::Group
|
present @groups, with: Entities::Group
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Create group. Available only for admin
|
# Create group. Available only for admin
|
||||||
|
@ -42,9 +45,12 @@ module Gitlab
|
||||||
# GET /groups/:id
|
# GET /groups/:id
|
||||||
get ":id" do
|
get ":id" do
|
||||||
@group = Group.find(params[:id])
|
@group = Group.find(params[:id])
|
||||||
|
if current_user.admin or current_user.groups.include? @group
|
||||||
present @group, with: Entities::GroupDetail
|
present @group, with: Entities::GroupDetail
|
||||||
|
else
|
||||||
|
not_found!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue