diff options
author | Phil Hughes <me@iamphill.com> | 2017-08-30 16:49:22 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-08-30 16:49:22 +0100 |
commit | 4d2d744ae9a2d4c3bb0f00805c27704b79e00d72 (patch) | |
tree | 839b1c3ab4c09c80f7d643fe69dae8a83c4e4eb4 /lib/api/users.rb | |
parent | 25a3b7fab905d09f6f064108f457a4e20c8915ff (diff) | |
parent | f7c8434c7100c3c87eb2a75cd5a128e520d8c110 (diff) | |
download | gitlab-ce-enable-new-navigaton-by-default.tar.gz |
Merge branch 'master' into enable-new-navigaton-by-defaultenable-new-navigaton-by-default
Diffstat (limited to 'lib/api/users.rb')
-rw-r--r-- | lib/api/users.rb | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb index e2019d6d512..96f47bb618a 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -230,8 +230,7 @@ module API key = user.keys.find_by(id: params[:key_id]) not_found!('Key') unless key - status 204 - key.destroy + destroy_conditionally!(key) end desc 'Add an email address to a specified user. Available only for admins.' do @@ -287,7 +286,11 @@ module API email = user.emails.find_by(id: params[:email_id]) not_found!('Email') unless email - Emails::DestroyService.new(user, email: email.email).execute + destroy_conditionally!(email) do |email| + Emails::DestroyService.new(current_user, email: email.email).execute + end + + user.update_secondary_emails! end desc 'Delete a user. Available only for admins.' do @@ -299,11 +302,13 @@ module API end delete ":id" do authenticated_as_admin! + user = User.find_by(id: params[:id]) not_found!('User') unless user - status 204 - user.delete_async(deleted_by: current_user, params: params) + destroy_conditionally!(user) do + user.delete_async(deleted_by: current_user, params: params) + end end desc 'Block a user. Available only for admins.' @@ -403,8 +408,11 @@ module API requires :impersonation_token_id, type: Integer, desc: 'The ID of the impersonation token' end delete ':impersonation_token_id' do - status 204 - find_impersonation_token.revoke! + token = find_impersonation_token + + destroy_conditionally!(token) do + token.revoke! + end end end end @@ -481,8 +489,7 @@ module API key = current_user.keys.find_by(id: params[:key_id]) not_found!('Key') unless key - status 204 - key.destroy + destroy_conditionally!(key) end desc "Get the currently authenticated user's email addresses" do @@ -533,8 +540,11 @@ module API email = current_user.emails.find_by(id: params[:email_id]) not_found!('Email') unless email - status 204 - Emails::DestroyService.new(current_user, email: email.email).execute + destroy_conditionally!(email) do |email| + Emails::DestroyService.new(current_user, email: email.email).execute + end + + current_user.update_secondary_emails! end desc 'Get a list of user activities' |