Sha256: 798e79fdc9c36e772a9708731cf35a9656588e8d5c1d92d971778e9a71c80a29

Contents?: true

Size: 554 Bytes

Versions: 2

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

2 entries across 2 versions & 1 rubygems

Version Path
quilt_rails-3.6.0 lib/quilt_rails/trusted_ui_server_csrf_strategy.rb
quilt_rails-3.5.6 lib/quilt_rails/trusted_ui_server_csrf_strategy.rb