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 9, 2025
1 parent cab93bf commit 48bd82d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/controllers/api/v2/registration_tokens_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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
Expand Down

0 comments on commit 48bd82d

Please sign in to comment.