diff options
author | Thiago Presa <tpresa@gitlab.com> | 2019-03-22 09:54:03 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-03-22 09:54:03 +0000 |
commit | 538741f2303f03e520d0bbfea150da6754f5a995 (patch) | |
tree | d7e04fc2f5e60ed94e7109eca6a574499e85b458 /lib/api | |
parent | e14b4b051ef4fda565b50b8d92644ab046dfcdbf (diff) | |
download | gitlab-ce-538741f2303f03e520d0bbfea150da6754f5a995.tar.gz |
Add highest_role method to User
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | lib/api/users.rb | 2 |
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 |