diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | lib/api/users.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/access.rb | 14 |
3 files changed, 19 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 diff --git a/lib/gitlab/access.rb b/lib/gitlab/access.rb index ec090aea784..6c8ca8f219c 100644 --- a/lib/gitlab/access.rb +++ b/lib/gitlab/access.rb @@ -46,6 +46,12 @@ module Gitlab ) end + def options_with_none + options_with_owner.merge( + "None" => NO_ACCESS + ) + end + def sym_options { guest: GUEST, @@ -75,12 +81,20 @@ module Gitlab def human_access(access) options_with_owner.key(access) end + + def human_access_with_none(access) + options_with_none.key(access) + end end def human_access Gitlab::Access.human_access(access_field) end + def human_access_with_none + Gitlab::Access.human_access_with_none(access_field) + end + def owner? access_field == OWNER end |