Sha256: ca068cd53cfd5a38a732c253c0a1977d546c5c7b968e7eaaeb65b5a8fb976f4f

Contents?: true

Size: 554 Bytes

Versions: 27

Compression:

Stored size: 554 Bytes

Contents

# frozen_string_literal: true

module Quilt
  class TrustedUiServerCsrfStrategy
    def initialize(controller)
      @controller = controller
    end

    def handle_unverified_request
      return if node_server_side_render?

      fallback_handler.handle_unverified_request
    end

    private

    def node_server_side_render?
      @controller.request.headers['x-shopify-server-side-rendered'] == '1'
    end

    def fallback_handler
      ActionController::RequestForgeryProtection::ProtectionMethods::Exception.new(@controller)
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
quilt_rails-1.10.0 lib/quilt_rails/trusted_ui_server_csrf_strategy.rb
quilt_rails-1.9.2 lib/quilt_rails/trusted_ui_server_csrf_strategy.rb
quilt_rails-1.9.1 lib/quilt_rails/trusted_ui_server_csrf_strategy.rb
quilt_rails-1.9.0 lib/quilt_rails/trusted_ui_server_csrf_strategy.rb
quilt_rails-1.8.0 lib/quilt_rails/trusted_ui_server_csrf_strategy.rb
quilt_rails-1.7.0 lib/quilt_rails/trusted_ui_server_csrf_strategy.rb
quilt_rails-1.6.0 lib/quilt_rails/trusted_ui_server_csrf_strategy.rb