This commit is contained in:
Matt Jankowski 2025-09-03 20:07:44 +00:00 committed by GitHub
commit bb7064f7a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 12 deletions

View File

@ -0,0 +1,20 @@
# frozen_string_literal: true
module Settings
class Applications::TokensController < BaseController
before_action :set_application
def destroy
@access_token = current_user.token_for_app(@application)
@access_token.destroy
redirect_to settings_application_path(@application), notice: t('applications.token_regenerated')
end
private
def set_application
@application = current_user.applications.find(params[:application_id])
end
end
end

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
class Settings::ApplicationsController < Settings::BaseController
before_action :set_application, only: [:show, :update, :destroy, :regenerate]
before_action :set_application, only: [:show, :update, :destroy]
def index
@applications = current_user.applications.order(id: :desc).page(params[:page])
@ -45,13 +45,6 @@ class Settings::ApplicationsController < Settings::BaseController
redirect_to settings_applications_path, notice: I18n.t('applications.destroyed')
end
def regenerate
@access_token = current_user.token_for_app(@application)
@access_token.destroy
redirect_to settings_application_path(@application), notice: I18n.t('applications.token_regenerated')
end
private
def set_application

View File

@ -20,7 +20,7 @@
%code= current_user.token_for_app(@application).token
%tr
%th
%td= table_link_to 'refresh', t('applications.regenerate_token'), regenerate_settings_application_path(@application), method: :post
%td= table_link_to 'refresh', t('applications.regenerate_token'), settings_application_token_path(@application), method: :delete
%hr/

View File

@ -54,9 +54,7 @@ namespace :settings do
end
resources :applications, except: [:edit] do
member do
post :regenerate
end
resource :token, module: :applications, only: :destroy
end
resource :delete, only: [:show, :destroy]