Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-15 21:10:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-15 21:10:04 +0300
commit5ff1f808adf841bca979cb2fac6bdfa9c449d028 (patch)
treec95cfbbcb400684b2bc89fee4fc7b614315ba909 /lib/api/users.rb
parentf8a5275c45ed2276daf843764113476749e680d2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api/users.rb')
-rw-r--r--lib/api/users.rb11
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb
index 505fcb2b38e..3d9af536c3c 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -758,16 +758,11 @@ module API
break if user.deactivated?
- unless user.can_be_deactivated?
- forbidden!('A blocked user cannot be deactivated by the API') if user.blocked?
- forbidden!('An internal user cannot be deactivated by the API') if user.internal?
- forbidden!("The user you are trying to deactivate has been active in the past #{Gitlab::CurrentSettings.deactivate_dormant_users_period} days and cannot be deactivated")
- end
-
- if user.deactivate
+ result = ::Users::DeactivateService.new(current_user, skip_authorization: true).execute(user)
+ if result[:status] == :success
true
else
- render_api_error!(user.errors.full_messages, 400)
+ render_api_error!(result[:message], result[:reason] || :bad_request)
end
end
# rubocop: enable CodeReuse/ActiveRecord