Remove duplicate cache header setting before action (#33833)
This commit is contained in:
		
							parent
							
								
									8dce5138dd
								
							
						
					
					
						commit
						c3419d146a
					
				@ -7,17 +7,12 @@ module Admin
 | 
			
		||||
 | 
			
		||||
    layout 'admin'
 | 
			
		||||
 | 
			
		||||
    before_action :set_cache_headers
 | 
			
		||||
    before_action :set_referrer_policy_header
 | 
			
		||||
 | 
			
		||||
    after_action :verify_authorized
 | 
			
		||||
 | 
			
		||||
    private
 | 
			
		||||
 | 
			
		||||
    def set_cache_headers
 | 
			
		||||
      response.cache_control.replace(private: true, no_store: true)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def set_referrer_policy_header
 | 
			
		||||
      response.headers['Referrer-Policy'] = 'same-origin'
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -12,7 +12,6 @@ class Auth::RegistrationsController < Devise::RegistrationsController
 | 
			
		||||
  before_action :set_sessions, only: [:edit, :update]
 | 
			
		||||
  before_action :set_strikes, only: [:edit, :update]
 | 
			
		||||
  before_action :require_not_suspended!, only: [:update]
 | 
			
		||||
  before_action :set_cache_headers, only: [:edit, :update]
 | 
			
		||||
  before_action :set_rules, only: :new
 | 
			
		||||
  before_action :require_rules_acceptance!, only: :new
 | 
			
		||||
  before_action :set_registration_form_time, only: :new
 | 
			
		||||
@ -139,10 +138,6 @@ class Auth::RegistrationsController < Devise::RegistrationsController
 | 
			
		||||
    set_locale { render :rules }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_cache_headers
 | 
			
		||||
    response.cache_control.replace(private: true, no_store: true)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def is_flashing_format? # rubocop:disable Naming/PredicateName
 | 
			
		||||
    if params[:action] == 'create'
 | 
			
		||||
      false # Disable flash messages for sign-up
 | 
			
		||||
 | 
			
		||||
@ -8,11 +8,4 @@ class Disputes::BaseController < ApplicationController
 | 
			
		||||
  skip_before_action :require_functional!
 | 
			
		||||
 | 
			
		||||
  before_action :authenticate_user!
 | 
			
		||||
  before_action :set_cache_headers
 | 
			
		||||
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def set_cache_headers
 | 
			
		||||
    response.cache_control.replace(private: true, no_store: true)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,6 @@ class Filters::StatusesController < ApplicationController
 | 
			
		||||
  before_action :authenticate_user!
 | 
			
		||||
  before_action :set_filter
 | 
			
		||||
  before_action :set_status_filters
 | 
			
		||||
  before_action :set_cache_headers
 | 
			
		||||
 | 
			
		||||
  PER_PAGE = 20
 | 
			
		||||
 | 
			
		||||
@ -40,8 +39,4 @@ class Filters::StatusesController < ApplicationController
 | 
			
		||||
  def action_from_button
 | 
			
		||||
    'remove' if params[:remove]
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_cache_headers
 | 
			
		||||
    response.cache_control.replace(private: true, no_store: true)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,6 @@ class FiltersController < ApplicationController
 | 
			
		||||
 | 
			
		||||
  before_action :authenticate_user!
 | 
			
		||||
  before_action :set_filter, only: [:edit, :update, :destroy]
 | 
			
		||||
  before_action :set_cache_headers
 | 
			
		||||
 | 
			
		||||
  def index
 | 
			
		||||
    @filters = current_account.custom_filters.includes(:keywords, :statuses).order(:phrase)
 | 
			
		||||
@ -50,8 +49,4 @@ class FiltersController < ApplicationController
 | 
			
		||||
  def resource_params
 | 
			
		||||
    params.expect(custom_filter: [:title, :expires_in, :filter_action, context: [], keywords_attributes: [[:id, :keyword, :whole_word, :_destroy]]])
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_cache_headers
 | 
			
		||||
    response.cache_control.replace(private: true, no_store: true)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,6 @@ class InvitesController < ApplicationController
 | 
			
		||||
  layout 'admin'
 | 
			
		||||
 | 
			
		||||
  before_action :authenticate_user!
 | 
			
		||||
  before_action :set_cache_headers
 | 
			
		||||
 | 
			
		||||
  def index
 | 
			
		||||
    authorize :invite, :create?
 | 
			
		||||
@ -45,8 +44,4 @@ class InvitesController < ApplicationController
 | 
			
		||||
  def resource_params
 | 
			
		||||
    params.expect(invite: [:max_uses, :expires_in, :autofollow, :comment])
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_cache_headers
 | 
			
		||||
    response.cache_control.replace(private: true, no_store: true)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,6 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
 | 
			
		||||
 | 
			
		||||
  before_action :store_current_location
 | 
			
		||||
  before_action :authenticate_resource_owner!
 | 
			
		||||
  before_action :set_cache_headers
 | 
			
		||||
 | 
			
		||||
  content_security_policy do |p|
 | 
			
		||||
    p.form_action(false)
 | 
			
		||||
@ -32,8 +31,4 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
 | 
			
		||||
  def truthy_param?(key)
 | 
			
		||||
    ActiveModel::Type::Boolean.new.cast(params[key])
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_cache_headers
 | 
			
		||||
    response.cache_control.replace(private: true, no_store: true)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,6 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio
 | 
			
		||||
  before_action :store_current_location
 | 
			
		||||
  before_action :authenticate_resource_owner!
 | 
			
		||||
  before_action :require_not_suspended!, only: :destroy
 | 
			
		||||
  before_action :set_cache_headers
 | 
			
		||||
 | 
			
		||||
  before_action :set_last_used_at_by_app, only: :index, unless: -> { request.format == :json }
 | 
			
		||||
 | 
			
		||||
@ -30,10 +29,6 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio
 | 
			
		||||
    forbidden if current_account.unavailable?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_cache_headers
 | 
			
		||||
    response.cache_control.replace(private: true, no_store: true)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_last_used_at_by_app
 | 
			
		||||
    @last_used_at_by_app = current_resource_owner.applications_last_used
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,6 @@ class RelationshipsController < ApplicationController
 | 
			
		||||
  before_action :authenticate_user!
 | 
			
		||||
  before_action :set_accounts, only: :show
 | 
			
		||||
  before_action :set_relationships, only: :show
 | 
			
		||||
  before_action :set_cache_headers
 | 
			
		||||
 | 
			
		||||
  helper_method :following_relationship?, :followed_by_relationship?, :mutual_relationship?
 | 
			
		||||
 | 
			
		||||
@ -66,8 +65,4 @@ class RelationshipsController < ApplicationController
 | 
			
		||||
      'remove_domains_from_followers'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_cache_headers
 | 
			
		||||
    response.cache_control.replace(private: true, no_store: true)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -4,14 +4,9 @@ class Settings::BaseController < ApplicationController
 | 
			
		||||
  layout 'admin'
 | 
			
		||||
 | 
			
		||||
  before_action :authenticate_user!
 | 
			
		||||
  before_action :set_cache_headers
 | 
			
		||||
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def set_cache_headers
 | 
			
		||||
    response.cache_control.replace(private: true, no_store: true)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def require_not_suspended!
 | 
			
		||||
    forbidden if current_account.unavailable?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,6 @@ class SeveredRelationshipsController < ApplicationController
 | 
			
		||||
  layout 'admin'
 | 
			
		||||
 | 
			
		||||
  before_action :authenticate_user!
 | 
			
		||||
  before_action :set_cache_headers
 | 
			
		||||
 | 
			
		||||
  before_action :set_event, only: [:following, :followers]
 | 
			
		||||
 | 
			
		||||
@ -49,8 +48,4 @@ class SeveredRelationshipsController < ApplicationController
 | 
			
		||||
  def acct(account)
 | 
			
		||||
    account.local? ? account.local_username_and_domain : account.acct
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_cache_headers
 | 
			
		||||
    response.cache_control.replace(private: true, no_store: true)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,6 @@ class StatusesCleanupController < ApplicationController
 | 
			
		||||
 | 
			
		||||
  before_action :authenticate_user!
 | 
			
		||||
  before_action :set_policy
 | 
			
		||||
  before_action :set_cache_headers
 | 
			
		||||
 | 
			
		||||
  def show; end
 | 
			
		||||
 | 
			
		||||
@ -30,8 +29,4 @@ class StatusesCleanupController < ApplicationController
 | 
			
		||||
  def resource_params
 | 
			
		||||
    params.expect(account_statuses_cleanup_policy: [:enabled, :min_status_age, :keep_direct, :keep_pinned, :keep_polls, :keep_media, :keep_self_fav, :keep_self_bookmark, :min_favs, :min_reblogs])
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_cache_headers
 | 
			
		||||
    response.cache_control.replace(private: true, no_store: true)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user