From 361818e931eff47db937ffa18d89575e2a9dd5be Mon Sep 17 00:00:00 2001 From: ysksn Date: Tue, 11 Dec 2018 05:37:38 +0900 Subject: Fix Admin::TagsController#unhide (#9481) --- app/controllers/admin/tags_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb index 3f2256566..e9f4f2cfa 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/admin/tags_controller.rb @@ -18,7 +18,7 @@ module Admin def unhide authorize @tag, :unhide? - @tag.account_tag_stat.update!(hidden: true) + @tag.account_tag_stat.update!(hidden: false) redirect_to admin_tags_path(@filter_params) end -- cgit From 189a6b17fb4b33f67614494dc76df87bcb95b812 Mon Sep 17 00:00:00 2001 From: ysksn Date: Tue, 11 Dec 2018 05:38:01 +0900 Subject: Remove RemoteAccountControllerConcern never used (#9482) --- .../concerns/remote_account_controller_concern.rb | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 app/controllers/concerns/remote_account_controller_concern.rb (limited to 'app/controllers') diff --git a/app/controllers/concerns/remote_account_controller_concern.rb b/app/controllers/concerns/remote_account_controller_concern.rb deleted file mode 100644 index e17910642..000000000 --- a/app/controllers/concerns/remote_account_controller_concern.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -module RemoteAccountControllerConcern - extend ActiveSupport::Concern - - included do - layout 'public' - before_action :set_account - before_action :check_account_suspension - end - - private - - def set_account - @account = Account.find_remote!(params[:acct]) - end - - def check_account_suspension - gone if @account.suspended? - end -end -- cgit From ed24bb2c3ecf82521be0685f59ecdee77c6fff39 Mon Sep 17 00:00:00 2001 From: ysksn Date: Tue, 11 Dec 2018 05:39:25 +0900 Subject: Add specs for activitypub collections controller (#9484) * Add specs for ActivityPub::CollectionsController#show * Raise ActiveRecord::RecordNotFound Raising ActiveRecord::NotFound raises NameError: uninitialized constant ActiveRecord::NotFound. --- .../activitypub/collections_controller.rb | 4 ++-- .../activitypub/collections_controller_spec.rb | 25 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 spec/controllers/activitypub/collections_controller_spec.rb (limited to 'app/controllers') diff --git a/app/controllers/activitypub/collections_controller.rb b/app/controllers/activitypub/collections_controller.rb index 96bf901a7..995da9c55 100644 --- a/app/controllers/activitypub/collections_controller.rb +++ b/app/controllers/activitypub/collections_controller.rb @@ -31,7 +31,7 @@ class ActivityPub::CollectionsController < Api::BaseController when 'featured' @account.pinned_statuses.count else - raise ActiveRecord::NotFound + raise ActiveRecord::RecordNotFound end end @@ -42,7 +42,7 @@ class ActivityPub::CollectionsController < Api::BaseController scope.merge!(@account.pinned_statuses) end else - raise ActiveRecord::NotFound + raise ActiveRecord::RecordNotFound end end diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb new file mode 100644 index 000000000..34114cc85 --- /dev/null +++ b/spec/controllers/activitypub/collections_controller_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe ActivityPub::CollectionsController, type: :controller do + describe 'POST #show' do + let(:account) { Fabricate(:account) } + + context 'id is "featured"' do + it 'returns 200 with "application/activity+json"' do + post :show, params: { id: 'featured', account_username: account.username } + + expect(response).to have_http_status(200) + expect(response.content_type).to eq 'application/activity+json' + end + end + + context 'id is not "featured"' do + it 'returns 404' do + post :show, params: { id: 'hoge', account_username: account.username } + expect(response).to have_http_status(404) + end + end + end +end -- cgit From 720daa81435b4c632cdf7b64044cf1ee59af977a Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 11 Dec 2018 19:18:29 +0100 Subject: Add instance-wide setting to disable profile directory (#9497) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add instance-wide setting to disable profile directory Fixes #9496 When the profile directory is disabled: - The “discoverable” setting is hidden from users - The “profile directory” link is not shown on public pages - /explore returns 404 * Move Setting.profile_directory check to a before_action filter --- app/controllers/admin/dashboard_controller.rb | 1 + app/controllers/admin/settings_controller.rb | 2 ++ app/controllers/directories_controller.rb | 5 +++++ app/models/form/admin_settings.rb | 2 ++ app/views/admin/dashboard/index.html.haml | 6 ++++++ app/views/admin/settings/edit.html.haml | 3 +++ app/views/layouts/public.html.haml | 3 ++- app/views/settings/profiles/show.html.haml | 5 +++-- config/locales/en.yml | 4 ++++ config/settings.yml | 1 + 10 files changed, 29 insertions(+), 3 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 7be753c9b..bb923c185 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -28,6 +28,7 @@ module Admin @pam_enabled = ENV['PAM_ENABLED'] == 'true' @hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true' @trending_hashtags = TrendingTags.get(7) + @profile_directory = Setting.profile_directory end private diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index d9f261489..4a049fc23 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -26,6 +26,7 @@ module Admin show_known_fediverse_at_about_page preview_sensitive_media custom_css + profile_directory ).freeze BOOLEAN_SETTINGS = %w( @@ -37,6 +38,7 @@ module Admin peers_api_enabled show_known_fediverse_at_about_page preview_sensitive_media + profile_directory ).freeze UPLOAD_SETTINGS = %w( diff --git a/app/controllers/directories_controller.rb b/app/controllers/directories_controller.rb index 265fd5fab..b8565af4b 100644 --- a/app/controllers/directories_controller.rb +++ b/app/controllers/directories_controller.rb @@ -3,6 +3,7 @@ class DirectoriesController < ApplicationController layout 'public' + before_action :check_enabled before_action :set_instance_presenter before_action :set_tag, only: :show before_action :set_tags @@ -18,6 +19,10 @@ class DirectoriesController < ApplicationController private + def check_enabled + return not_found unless Setting.profile_directory + end + def set_tag @tag = Tag.discoverable.find_by!(name: params[:id].downcase) end diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 9fef7da97..eca71bf62 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -44,6 +44,8 @@ class Form::AdminSettings :preview_sensitive_media=, :custom_css, :custom_css=, + :profile_directory, + :profile_directory=, to: Setting ) end diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index 1996eef4d..fa3d70e9e 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -57,6 +57,12 @@ %span.pull-right.positive-hint= fa_icon 'check fw' - else %span.pull-right.negative-hint= fa_icon 'times fw' + %li + = link_to t('admin.dashboard.feature_profile_directory'), edit_admin_settings_path + - if @profile_directory + %span.pull-right.positive-hint= fa_icon 'check fw' + - else + %span.pull-right.negative-hint= fa_icon 'times fw' %li = link_to t('admin.dashboard.feature_relay'), admin_relays_path - if @relay_enabled diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index 04b1a6754..7afa9ec37 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -62,6 +62,9 @@ .fields-group = f.input :preview_sensitive_media, as: :boolean, wrapper: :with_label, label: t('admin.settings.preview_sensitive_media.title'), hint: t('admin.settings.preview_sensitive_media.desc_html') + .fields-group + = f.input :profile_directory, as: :boolean, wrapper: :with_label, label: t('admin.settings.profile_directory.title'), hint: t('admin.settings.profile_directory.desc_html') + %hr.spacer/ .fields-group diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index 831c7f012..93ed12f18 100644 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/public.html.haml @@ -9,7 +9,8 @@ = link_to root_url, class: 'brand' do = image_tag asset_pack_path('logo_full.svg'), alt: 'Mastodon' - = link_to t('directories.directory'), explore_path, class: 'nav-link' + - if Setting.profile_directory + = link_to t('directories.directory'), explore_path, class: 'nav-link' = link_to t('about.about_this'), about_more_path, class: 'nav-link' = link_to t('about.apps'), 'https://joinmastodon.org/apps', class: 'nav-link' .nav-center diff --git a/app/views/settings/profiles/show.html.haml b/app/views/settings/profiles/show.html.haml index fa3869f6f..eb232dc57 100644 --- a/app/views/settings/profiles/show.html.haml +++ b/app/views/settings/profiles/show.html.haml @@ -26,8 +26,9 @@ .fields-group = f.input :bot, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.bot') - .fields-group - = f.input :discoverable, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.discoverable_html', min_followers: Account::MIN_FOLLOWERS_DISCOVERY, path: explore_path) + - if Setting.profile_directory + .fields-group + = f.input :discoverable, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.discoverable_html', min_followers: Account::MIN_FOLLOWERS_DISCOVERY, path: explore_path) %hr.spacer/ diff --git a/config/locales/en.yml b/config/locales/en.yml index 243b513fd..314787acd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -229,6 +229,7 @@ en: config: Configuration feature_deletions: Account deletions feature_invites: Invite links + feature_profile_directory: Profile directory feature_registrations: Registrations feature_relay: Federation relay features: Features @@ -376,6 +377,9 @@ en: preview_sensitive_media: desc_html: Link previews on other websites will display a thumbnail even if the media is marked as sensitive title: Show sensitive media in OpenGraph previews + profile_directory: + desc_html: Allow users to be discoverable + title: Enable profile directory registrations: closed_message: desc_html: Displayed on frontpage when registrations are closed. You can use HTML tags diff --git a/config/settings.yml b/config/settings.yml index 4036d419f..b3d2e0240 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -15,6 +15,7 @@ defaults: &defaults site_contact_username: '' site_contact_email: '' open_registrations: true + profile_directory: true closed_registrations_message: '' open_deletion: true min_invite_role: 'admin' -- cgit From cf6ee4ff243b66b2b53faaceed1266999b84c3c1 Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 11 Dec 2018 19:28:03 +0100 Subject: Add admin ability to remove an user's header image (#9495) * Fix markup in admin/accounts/:id table for avatar * Add admin ability to remove an user's header image --- app/controllers/admin/accounts_controller.rb | 13 ++++++++++++- app/helpers/admin/action_logs_helper.rb | 2 +- app/policies/account_policy.rb | 4 ++++ app/views/admin/accounts/show.html.haml | 9 ++++++++- config/routes.rb | 1 + 5 files changed, 26 insertions(+), 3 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/accounts_controller.rb b/app/controllers/admin/accounts_controller.rb index f155543ce..771302db8 100644 --- a/app/controllers/admin/accounts_controller.rb +++ b/app/controllers/admin/accounts_controller.rb @@ -2,7 +2,7 @@ module Admin class AccountsController < BaseController - before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :remove_avatar, :enable, :disable, :memorialize] + before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :remove_avatar, :remove_header, :enable, :disable, :memorialize] before_action :require_remote_account!, only: [:subscribe, :unsubscribe, :redownload] before_action :require_local_account!, only: [:enable, :disable, :memorialize] @@ -71,6 +71,17 @@ module Admin redirect_to admin_account_path(@account.id) end + def remove_header + authorize @account, :remove_header? + + @account.header = nil + @account.save! + + log_action :remove_header, @account.user + + redirect_to admin_account_path(@account.id) + end + private def set_account diff --git a/app/helpers/admin/action_logs_helper.rb b/app/helpers/admin/action_logs_helper.rb index c28f0be6b..68cf8c75d 100644 --- a/app/helpers/admin/action_logs_helper.rb +++ b/app/helpers/admin/action_logs_helper.rb @@ -92,7 +92,7 @@ module Admin::ActionLogsHelper opposite_verbs?(log) ? 'negative' : 'positive' when :update, :reset_password, :disable_2fa, :memorialize, :change_email 'neutral' - when :demote, :silence, :disable, :suspend, :remove_avatar, :reopen + when :demote, :silence, :disable, :suspend, :remove_avatar, :remove_header, :reopen 'negative' when :destroy opposite_verbs?(log) ? 'positive' : 'negative' diff --git a/app/policies/account_policy.rb b/app/policies/account_policy.rb index efabe80d0..07bae68ef 100644 --- a/app/policies/account_policy.rb +++ b/app/policies/account_policy.rb @@ -33,6 +33,10 @@ class AccountPolicy < ApplicationPolicy staff? end + def remove_header? + staff? + end + def subscribe? admin? end diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml index c1a5fc1bd..e9f765107 100644 --- a/app/views/admin/accounts/show.html.haml +++ b/app/views/admin/accounts/show.html.haml @@ -16,11 +16,18 @@ %tr %th= t('admin.accounts.avatar') - %th + %td = link_to @account.avatar.url(:original) do = image_tag @account.avatar.url(:original), alt: '', width: 40, height: 40, class: 'avatar' - if @account.local? && @account.avatar? = table_link_to 'trash', t('admin.accounts.remove_avatar'), remove_avatar_admin_account_path(@account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if can?(:remove_avatar, @account) + %tr + %th= t('admin.accounts.header') + %td + = link_to @account.header.url(:original) do + = image_tag @account.header.url(:original), alt: '', width: 128, height: 40, class: 'header' + - if @account.local? && @account.header? + = table_link_to 'trash', t('admin.accounts.remove_header'), remove_header_admin_account_path(@account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if can?(:remove_header, @account) - if @account.local? %tr diff --git a/config/routes.rb b/config/routes.rb index 262868413..4a0289465 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -176,6 +176,7 @@ Rails.application.routes.draw do post :disable post :redownload post :remove_avatar + post :remove_header post :memorialize end -- cgit From b048926e678e5b642cb1e939f629236e77944523 Mon Sep 17 00:00:00 2001 From: ysksn Date: Thu, 13 Dec 2018 06:32:13 +0900 Subject: Create Settings::BaseController (#9507) Define `Settings::BaseController#set_body_classes` so that sub classes inherit `Settings::BaseController` don't need to define `#set_body_classes` agein. --- app/controllers/settings/applications_controller.rb | 7 +------ app/controllers/settings/base_controller.rb | 11 +++++++++++ app/controllers/settings/deletes_controller.rb | 7 +------ app/controllers/settings/exports_controller.rb | 9 +-------- app/controllers/settings/follower_domains_controller.rb | 7 +------ app/controllers/settings/imports_controller.rb | 7 +------ app/controllers/settings/migrations_controller.rb | 7 +------ app/controllers/settings/notifications_controller.rb | 7 +------ app/controllers/settings/preferences_controller.rb | 7 +------ app/controllers/settings/profiles_controller.rb | 7 +------ app/controllers/settings/sessions_controller.rb | 7 +------ .../two_factor_authentication/confirmations_controller.rb | 7 +------ .../two_factor_authentication/recovery_codes_controller.rb | 9 +-------- .../settings/two_factor_authentications_controller.rb | 7 +------ 14 files changed, 24 insertions(+), 82 deletions(-) create mode 100644 app/controllers/settings/base_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/settings/applications_controller.rb b/app/controllers/settings/applications_controller.rb index a1a2c57fa..ed3f82a8e 100644 --- a/app/controllers/settings/applications_controller.rb +++ b/app/controllers/settings/applications_controller.rb @@ -1,12 +1,11 @@ # 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]) @@ -70,8 +69,4 @@ class Settings::ApplicationsController < ApplicationController 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 diff --git a/app/controllers/settings/base_controller.rb b/app/controllers/settings/base_controller.rb new file mode 100644 index 000000000..9bb14afa2 --- /dev/null +++ b/app/controllers/settings/base_controller.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class Settings::BaseController < ApplicationController + before_action :set_body_classes + + private + + def set_body_classes + @body_classes = 'admin' + end +end diff --git a/app/controllers/settings/deletes_controller.rb b/app/controllers/settings/deletes_controller.rb index 97f3946c8..dd19aadf6 100644 --- a/app/controllers/settings/deletes_controller.rb +++ b/app/controllers/settings/deletes_controller.rb @@ -1,11 +1,10 @@ # 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 @@ -30,8 +29,4 @@ class Settings::DeletesController < ApplicationController def delete_params params.require(:form_delete_confirmation).permit(:password) end - - def set_body_classes - @body_classes = 'admin' - end end diff --git a/app/controllers/settings/exports_controller.rb b/app/controllers/settings/exports_controller.rb index 3a2334ef0..0135f2189 100644 --- a/app/controllers/settings/exports_controller.rb +++ b/app/controllers/settings/exports_controller.rb @@ -1,12 +1,11 @@ # 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) @@ -21,10 +20,4 @@ class Settings::ExportsController < ApplicationController redirect_to settings_export_path end - - private - - def set_body_classes - @body_classes = 'admin' - end end diff --git a/app/controllers/settings/follower_domains_controller.rb b/app/controllers/settings/follower_domains_controller.rb index 9c39e66bb..ce8ec985d 100644 --- a/app/controllers/settings/follower_domains_controller.rb +++ b/app/controllers/settings/follower_domains_controller.rb @@ -1,10 +1,9 @@ # 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 @@ -26,8 +25,4 @@ class Settings::FollowerDomainsController < ApplicationController def bulk_params params.permit(select: []) end - - def set_body_classes - @body_classes = 'admin' - end end diff --git a/app/controllers/settings/imports_controller.rb b/app/controllers/settings/imports_controller.rb index e9548ce62..38f2e39c1 100644 --- a/app/controllers/settings/imports_controller.rb +++ b/app/controllers/settings/imports_controller.rb @@ -1,11 +1,10 @@ # 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 @@ -32,8 +31,4 @@ class Settings::ImportsController < ApplicationController def import_params params.require(:import).permit(:data, :type) end - - def set_body_classes - @body_classes = 'admin' - end end diff --git a/app/controllers/settings/migrations_controller.rb b/app/controllers/settings/migrations_controller.rb index bd4f9c87a..59eb48779 100644 --- a/app/controllers/settings/migrations_controller.rb +++ b/app/controllers/settings/migrations_controller.rb @@ -1,10 +1,9 @@ # 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) @@ -32,8 +31,4 @@ class Settings::MigrationsController < ApplicationController 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 diff --git a/app/controllers/settings/notifications_controller.rb b/app/controllers/settings/notifications_controller.rb index d0754296c..da8a03d96 100644 --- a/app/controllers/settings/notifications_controller.rb +++ b/app/controllers/settings/notifications_controller.rb @@ -1,10 +1,9 @@ # 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 @@ -30,8 +29,4 @@ class Settings::NotificationsController < ApplicationController interactions: %i(must_be_follower must_be_following must_be_following_dm) ) end - - def set_body_classes - @body_classes = 'admin' - end end diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 70e71b4a2..41df3bde2 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -1,10 +1,9 @@ # 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 @@ -53,8 +52,4 @@ class Settings::PreferencesController < ApplicationController interactions: %i(must_be_follower must_be_following) ) end - - def set_body_classes - @body_classes = 'admin' - end end diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index 20a55785c..db9081fdf 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -1,13 +1,12 @@ # 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] @@ -35,8 +34,4 @@ class Settings::ProfilesController < ApplicationController def set_account @account = current_user.account end - - def set_body_classes - @body_classes = 'admin' - end end diff --git a/app/controllers/settings/sessions_controller.rb b/app/controllers/settings/sessions_controller.rb index 74cebc07b..11b150ffd 100644 --- a/app/controllers/settings/sessions_controller.rb +++ b/app/controllers/settings/sessions_controller.rb @@ -1,8 +1,7 @@ # 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! @@ -15,8 +14,4 @@ class Settings::SessionsController < ApplicationController def set_session @session = current_user.session_activations.find(params[:id]) end - - def set_body_classes - @body_classes = 'admin' - end end diff --git a/app/controllers/settings/two_factor_authentication/confirmations_controller.rb b/app/controllers/settings/two_factor_authentication/confirmations_controller.rb index ee567c2a7..d87117a50 100644 --- a/app/controllers/settings/two_factor_authentication/confirmations_controller.rb +++ b/app/controllers/settings/two_factor_authentication/confirmations_controller.rb @@ -2,12 +2,11 @@ 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 @@ -44,10 +43,6 @@ module Settings 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 diff --git a/app/controllers/settings/two_factor_authentication/recovery_codes_controller.rb b/app/controllers/settings/two_factor_authentication/recovery_codes_controller.rb index bfb103620..c78166c65 100644 --- a/app/controllers/settings/two_factor_authentication/recovery_codes_controller.rb +++ b/app/controllers/settings/two_factor_authentication/recovery_codes_controller.rb @@ -2,11 +2,10 @@ 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! @@ -14,12 +13,6 @@ module Settings 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 diff --git a/app/controllers/settings/two_factor_authentications_controller.rb b/app/controllers/settings/two_factor_authentications_controller.rb index e4d8aed41..e12c43074 100644 --- a/app/controllers/settings/two_factor_authentications_controller.rb +++ b/app/controllers/settings/two_factor_authentications_controller.rb @@ -1,12 +1,11 @@ # 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 @@ -44,9 +43,5 @@ module Settings 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 -- cgit