Skip to content

Commit

Permalink
Refs #37936 - Correct success method for jwt api
Browse files Browse the repository at this point in the history
  • Loading branch information
girijaasoni committed Jan 17, 2025
1 parent 0ea2685 commit d91068e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/controllers/api/v2/registration_tokens_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
module Api
module V2
class RegistrationTokensController < V2::BaseController
include Foreman::Controller::UsersMixin
include Foreman::Controller::UserSelfEditing

include Foreman::Controller::Parameters::User
include Foreman::Controller::AutoCompleteSearch
before_action :authenticate, :only => [:invalidate_jwt_tokens, :invalidate_jwt]

def resource_class
Expand Down Expand Up @@ -36,7 +34,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 => { :message => _("Successfully invalidated registration tokens."), :user => login}, :status => :ok
end

api :DELETE, "/registration_tokens", N_("Invalidate all registration tokens for multiple users.")
Expand All @@ -51,7 +50,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 => { :message => _("Successfully invalidated registration tokens."), :users => login}, :status => :ok
end
end
end
Expand Down

0 comments on commit d91068e

Please sign in to comment.