# frozen_string_literal: true
-class Settings::ApplicationsController < ApplicationController
+class Settings::ApplicationsController < Settings::BaseController
layout 'admin'
before_action :authenticate_user!
before_action :set_application, only: [:show, :update, :destroy, :regenerate]
before_action :prepare_scopes, only: [:create, :update]
- before_action :set_body_classes
def index
@applications = current_user.applications.order(id: :desc).page(params[:page])
scopes = params.fetch(:doorkeeper_application, {}).fetch(:scopes, nil)
params[:doorkeeper_application][:scopes] = scopes.join(' ') if scopes.is_a? Array
end
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
--- /dev/null
+# frozen_string_literal: true
+
+class Settings::BaseController < ApplicationController
+ before_action :set_body_classes
+
+ private
+
+ def set_body_classes
+ @body_classes = 'admin'
+ end
+end
# frozen_string_literal: true
-class Settings::DeletesController < ApplicationController
+class Settings::DeletesController < Settings::BaseController
layout 'admin'
before_action :check_enabled_deletion
before_action :authenticate_user!
- before_action :set_body_classes
def show
@confirmation = Form::DeleteConfirmation.new
def delete_params
params.require(:form_delete_confirmation).permit(:password)
end
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
# frozen_string_literal: true
-class Settings::ExportsController < ApplicationController
+class Settings::ExportsController < Settings::BaseController
include Authorization
layout 'admin'
before_action :authenticate_user!
- before_action :set_body_classes
def show
@export = Export.new(current_account)
redirect_to settings_export_path
end
-
- private
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
# frozen_string_literal: true
-class Settings::FollowerDomainsController < ApplicationController
+class Settings::FollowerDomainsController < Settings::BaseController
layout 'admin'
before_action :authenticate_user!
- before_action :set_body_classes
def show
@account = current_account
def bulk_params
params.permit(select: [])
end
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
# frozen_string_literal: true
-class Settings::ImportsController < ApplicationController
+class Settings::ImportsController < Settings::BaseController
layout 'admin'
before_action :authenticate_user!
before_action :set_account
- before_action :set_body_classes
def show
@import = Import.new
def import_params
params.require(:import).permit(:data, :type)
end
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
# frozen_string_literal: true
-class Settings::MigrationsController < ApplicationController
+class Settings::MigrationsController < Settings::BaseController
layout 'admin'
before_action :authenticate_user!
- before_action :set_body_classes
def show
@migration = Form::Migration.new(account: current_account.moved_to_account)
current_account.moved_to_account_id != @migration.account&.id &&
current_account.id != @migration.account&.id
end
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
# frozen_string_literal: true
-class Settings::NotificationsController < ApplicationController
+class Settings::NotificationsController < Settings::BaseController
layout 'admin'
before_action :authenticate_user!
- before_action :set_body_classes
def show; end
interactions: %i(must_be_follower must_be_following must_be_following_dm)
)
end
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
# frozen_string_literal: true
-class Settings::PreferencesController < ApplicationController
+class Settings::PreferencesController < Settings::BaseController
layout 'admin'
before_action :authenticate_user!
- before_action :set_body_classes
def show; end
interactions: %i(must_be_follower must_be_following)
)
end
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
# frozen_string_literal: true
-class Settings::ProfilesController < ApplicationController
+class Settings::ProfilesController < Settings::BaseController
include ObfuscateFilename
layout 'admin'
before_action :authenticate_user!
before_action :set_account
- before_action :set_body_classes
obfuscate_filename [:account, :avatar]
obfuscate_filename [:account, :header]
def set_account
@account = current_user.account
end
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
# frozen_string_literal: true
-class Settings::SessionsController < ApplicationController
+class Settings::SessionsController < Settings::BaseController
before_action :set_session, only: :destroy
- before_action :set_body_classes
def destroy
@session.destroy!
def set_session
@session = current_user.session_activations.find(params[:id])
end
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
module Settings
module TwoFactorAuthentication
- class ConfirmationsController < ApplicationController
+ class ConfirmationsController < BaseController
layout 'admin'
before_action :authenticate_user!
before_action :ensure_otp_secret
- before_action :set_body_classes
def new
prepare_two_factor_form
def ensure_otp_secret
redirect_to settings_two_factor_authentication_path unless current_user.otp_secret
end
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
end
end
module Settings
module TwoFactorAuthentication
- class RecoveryCodesController < ApplicationController
+ class RecoveryCodesController < BaseController
layout 'admin'
before_action :authenticate_user!
- before_action :set_body_classes
def create
@recovery_codes = current_user.generate_otp_backup_codes!
flash[:notice] = I18n.t('two_factor_authentication.recovery_codes_regenerated')
render :index
end
-
- private
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
end
end
# frozen_string_literal: true
module Settings
- class TwoFactorAuthenticationsController < ApplicationController
+ class TwoFactorAuthenticationsController < BaseController
layout 'admin'
before_action :authenticate_user!
before_action :verify_otp_required, only: [:create]
- before_action :set_body_classes
def show
@confirmation = Form::TwoFactorConfirmation.new
current_user.validate_and_consume_otp!(confirmation_params[:code]) ||
current_user.invalidate_otp_backup_code!(confirmation_params[:code])
end
-
- def set_body_classes
- @body_classes = 'admin'
- end
end
end