diff options
Diffstat (limited to 'lib/api/users.rb')
-rw-r--r-- | lib/api/users.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb index 2608fb87e22..e3271b8b9b2 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -615,6 +615,22 @@ module API end end + desc 'Reject a pending user. Available only for admins.' + params do + requires :id, type: Integer, desc: 'The ID of the user' + end + post ':id/reject', feature_category: :authentication_and_authorization do + user = find_user_by_id(params) + + result = ::Users::RejectService.new(current_user).execute(user) + + if result[:success] + present user + else + render_api_error!(result[:message], result[:http_status]) + end + end + # rubocop: enable CodeReuse/ActiveRecord desc 'Deactivate an active user. Available only for admins.' params do @@ -687,6 +703,38 @@ module API end # rubocop: enable CodeReuse/ActiveRecord + desc 'Ban a user. Available only for admins.' + params do + requires :id, type: Integer, desc: 'The ID of the user' + end + post ':id/ban', feature_category: :authentication_and_authorization do + authenticated_as_admin! + user = find_user_by_id(params) + + result = ::Users::BanService.new(current_user).execute(user) + if result[:status] == :success + true + else + render_api_error!(result[:message], result[:http_status]) + end + end + + desc 'Unban a user. Available only for admins.' + params do + requires :id, type: Integer, desc: 'The ID of the user' + end + post ':id/unban', feature_category: :authentication_and_authorization do + authenticated_as_admin! + user = find_user_by_id(params) + + result = ::Users::UnbanService.new(current_user).execute(user) + if result[:status] == :success + true + else + render_api_error!(result[:message], result[:http_status]) + end + end + desc 'Get memberships' do success Entities::Membership end |