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/api
diff options
context:
space:
mode:
authorThiago Presa <tpresa@gitlab.com>2019-03-22 12:54:03 +0300
committerSean McGivern <sean@gitlab.com>2019-03-22 12:54:03 +0300
commit538741f2303f03e520d0bbfea150da6754f5a995 (patch)
treed7e04fc2f5e60ed94e7109eca6a574499e85b458 /lib/api
parente14b4b051ef4fda565b50b8d92644ab046dfcdbf (diff)
Add highest_role method to User
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/entities.rb4
-rw-r--r--lib/api/users.rb2
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 2cd0d93b205..611523a2444 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -86,6 +86,10 @@ module API
expose :admin?, as: :is_admin
end
+ class UserDetailsWithAdmin < UserWithAdmin
+ expose :highest_role
+ end
+
class UserStatus < Grape::Entity
expose :emoji
expose :message
diff --git a/lib/api/users.rb b/lib/api/users.rb
index 7d88880d412..a3d4acc63d5 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -124,7 +124,7 @@ module API
user = User.find_by(id: params[:id])
not_found!('User') unless user && can?(current_user, :read_user, user)
- opts = { with: current_user&.admin? ? Entities::UserWithAdmin : Entities::User, current_user: current_user }
+ opts = { with: current_user&.admin? ? Entities::UserDetailsWithAdmin : Entities::User, current_user: current_user }
user, opts = with_custom_attributes(user, opts)
present user, opts