1 # frozen_string_literal: true
3 class Settings
::ApplicationsController < ApplicationController
6 before_action
:authenticate_user!
7 before_action
:set_application, only
: [:show, :update, :destroy, :regenerate]
8 before_action
:prepare_scopes, only
: [:create, :update]
9 before_action
:set_body_classes
12 @applications = current_user
.applications
.order(id
: :desc).page(params
[:page])
16 @application = Doorkeeper
::Application.new(
17 redirect_uri
: Doorkeeper
.configuration
.native_redirect_uri
,
18 scopes
: 'read write follow'
25 @application = current_user
.applications
.build(application_params
)
28 redirect_to settings_applications_path
, notice
: I18n
.t('applications.created')
35 if @application.update(application_params
)
36 redirect_to settings_applications_path
, notice
: I18n
.t('generic.changes_saved_msg')
44 redirect_to settings_applications_path
, notice
: I18n
.t('applications.destroyed')
48 @access_token = current_user
.token_for_app(@application)
51 redirect_to
settings_application_path(@application), notice
: I18n
.t('applications.token_regenerated')
57 @application = current_user
.applications
.find(params
[:id])
60 def application_params
61 params
.require(:doorkeeper_application).permit(
70 scopes
= params
.fetch(:doorkeeper_application, {}).fetch(:scopes, nil)
71 params
[:doorkeeper_application][:scopes] = scopes
.join(' ') if scopes
.is_a
? Array
75 @body_classes = 'admin'