summaryrefslogtreecommitdiff
path: root/lib/api/users.rb
diff options
context:
space:
mode:
authorSaverio Miroddi <saverio.pub2@gmail.com>2017-08-15 18:49:28 +0200
committerSaverio Miroddi <saverio.pub2@gmail.com>2017-08-15 18:49:28 +0200
commitcd80a9075f5f2b3150c909a6cd56e7c8f239bd51 (patch)
tree58f0fba91c72ec86cc744f026d62d06050b20efa /lib/api/users.rb
parent1d6ba597028142511af8c9863f81073278ccd927 (diff)
parent97b768508c360d2ae767a559b5037fe464061440 (diff)
downloadgitlab-ce-cd80a9075f5f2b3150c909a6cd56e7c8f239bd51.tar.gz
Merge branch 'master' into sm-cherry-pick-list-commits-in-message
Diffstat (limited to 'lib/api/users.rb')
-rw-r--r--lib/api/users.rb13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb
index a590f2692a2..e2019d6d512 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -79,22 +79,17 @@ module API
end
desc 'Get a single user' do
- success Entities::UserBasic
+ success Entities::User
end
params do
requires :id, type: Integer, desc: 'The ID of the user'
end
get ":id" do
user = User.find_by(id: params[:id])
- not_found!('User') unless user
+ not_found!('User') unless user && can?(current_user, :read_user, user)
- if current_user && current_user.admin?
- present user, with: Entities::UserPublic
- elsif can?(current_user, :read_user, user)
- present user, with: Entities::User
- else
- render_api_error!("User not found.", 404)
- end
+ opts = current_user&.admin? ? { with: Entities::UserWithAdmin } : {}
+ present user, opts
end
desc 'Create a user. Available only for admins.' do