mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00
Merge 682839b0c0
into 14cb5ff881
This commit is contained in:
commit
bb7064f7a7
20
app/controllers/settings/applications/tokens_controller.rb
Normal file
20
app/controllers/settings/applications/tokens_controller.rb
Normal 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
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Settings::ApplicationsController < Settings::BaseController
|
class Settings::ApplicationsController < Settings::BaseController
|
||||||
before_action :set_application, only: [:show, :update, :destroy, :regenerate]
|
before_action :set_application, only: [:show, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@applications = current_user.applications.order(id: :desc).page(params[:page])
|
@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')
|
redirect_to settings_applications_path, notice: I18n.t('applications.destroyed')
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
def set_application
|
def set_application
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
%code= current_user.token_for_app(@application).token
|
%code= current_user.token_for_app(@application).token
|
||||||
%tr
|
%tr
|
||||||
%th
|
%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/
|
%hr/
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,7 @@ namespace :settings do
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :applications, except: [:edit] do
|
resources :applications, except: [:edit] do
|
||||||
member do
|
resource :token, module: :applications, only: :destroy
|
||||||
post :regenerate
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
resource :delete, only: [:show, :destroy]
|
resource :delete, only: [:show, :destroy]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user