From c6c7437861bff9572747674095c4dfbdfbea4988 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 4 Mar 2020 12:07:52 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- lib/api/users.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/api/users.rb') diff --git a/lib/api/users.rb b/lib/api/users.rb index c6dc7c08b11..5b51f114fb4 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -528,11 +528,18 @@ module API user = User.find_by(id: params[:id]) not_found!('User') unless user - if !user.ldap_blocked? - user.block - else + if user.ldap_blocked? forbidden!('LDAP blocked users cannot be modified by the API') end + + break if user.blocked? + + result = ::Users::BlockService.new(current_user).execute(user) + if result[:status] == :success + true + else + render_api_error!(result[:message], result[:http_status]) + end end # rubocop: enable CodeReuse/ActiveRecord -- cgit v1.2.1