From 48bd82d2b9313b3540ae4c7df5c52f7749361589 Mon Sep 17 00:00:00 2001 From: Girija Soni Date: Thu, 9 Jan 2025 17:20:36 +0530 Subject: [PATCH] Refs #37936 - Correct success method for jwt api --- app/controllers/api/v2/registration_tokens_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v2/registration_tokens_controller.rb b/app/controllers/api/v2/registration_tokens_controller.rb index e4e0ef569cc..3bdfc21fba2 100644 --- a/app/controllers/api/v2/registration_tokens_controller.rb +++ b/app/controllers/api/v2/registration_tokens_controller.rb @@ -36,7 +36,8 @@ def invalidate_jwt raise ::Foreman::Exception.new(N_("No record found for %s"), params[:id]) end @user.jwt_secret&.destroy - process_success _("Successfully invalidated registration tokens for %s.\n" % @user.login) + login = @user.login + render :json => {:status => 'success', :message => _("Successfully invalidated registration tokens for %s." % login), :user => login}, :status => :ok end api :DELETE, "/registration_tokens", N_("Invalidate all registration tokens for multiple users.") @@ -51,7 +52,8 @@ def invalidate_jwt_tokens if @users.blank? raise ::Foreman::Exception.new(N_("No record found for search '%s'"), params[:search]) end JwtSecret.where(user_id: @users).destroy_all - process_success _("Successfully invalidated registration tokens for %s.\n" % @users.pluck(:login).to_sentence) + login = @users.pluck(:login).to_sentence + render :json => {:status => 'success', :message => _("Successfully invalidated registration tokens for %s." % login), :users => login}, :status => :ok end end end