diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-03-31 14:27:38 +0100 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-03-31 14:30:59 +0100 |
commit | cdfa4a8b8332398fdb5e62d11ea0b33d89c0ef20 (patch) | |
tree | 8b2dab8e467819ddff8ac2afb12355c585974b48 | |
parent | acc2a03d924ec0b8fde8231e258830c103dffc59 (diff) | |
download | gitlab-ce-29903-remove-admin-status-from-user-endpoint.tar.gz |
moves is admin to user private information entity29903-remove-admin-status-from-user-endpoint
-rw-r--r-- | changelogs/unreleased/29903-remove-admin-status-from-user-endpoint.yml | 4 | ||||
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | lib/api/session.rb | 4 | ||||
-rw-r--r-- | lib/api/users.rb | 2 |
4 files changed, 9 insertions, 5 deletions
diff --git a/changelogs/unreleased/29903-remove-admin-status-from-user-endpoint.yml b/changelogs/unreleased/29903-remove-admin-status-from-user-endpoint.yml new file mode 100644 index 00000000000..19dd4d33c8c --- /dev/null +++ b/changelogs/unreleased/29903-remove-admin-status-from-user-endpoint.yml @@ -0,0 +1,4 @@ +--- +title: Move admin status to user private info entity +merge_request: 10380 +author: diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 5954aea8041..8f15a709da8 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -14,7 +14,6 @@ module API class User < UserBasic expose :created_at - expose :is_admin?, as: :is_admin expose :bio, :location, :skype, :linkedin, :twitter, :website_url, :organization end @@ -34,7 +33,8 @@ module API expose :external end - class UserWithPrivateToken < UserPublic + class UserWithPrivateInfo < UserPublic + expose :is_admin?, as: :is_admin expose :private_token end diff --git a/lib/api/session.rb b/lib/api/session.rb index 002ffd1d154..40c91968ac3 100644 --- a/lib/api/session.rb +++ b/lib/api/session.rb @@ -1,7 +1,7 @@ module API class Session < Grape::API desc 'Login to get token' do - success Entities::UserWithPrivateToken + success Entities::UserWithPrivateInfo end params do optional :login, type: String, desc: 'The username' @@ -14,7 +14,7 @@ module API return unauthorized! unless user return render_api_error!('401 Unauthorized. You have 2FA enabled. Please use a personal access token to access the API', 401) if user.two_factor_enabled? - present user, with: Entities::UserWithPrivateToken + present user, with: Entities::UserWithPrivateInfo end end end diff --git a/lib/api/users.rb b/lib/api/users.rb index a4201fe6fed..a21eb9bcacb 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -425,7 +425,7 @@ module API success Entities::UserPublic end get do - present current_user, with: sudo? ? Entities::UserWithPrivateToken : Entities::UserPublic + present current_user, with: sudo? ? Entities::UserWithPrivateInfo : Entities::UserPublic end desc "Get the currently authenticated user's SSH keys" do |