Sha256: 7a21580475b24bd8c8c65e1c7fac4a197447489ef8d351a7487c3d1a921d30d9

Contents?: true

Size: 1.06 KB

Versions: 31

Compression:

Stored size: 1.06 KB

Contents

module Smithy
  module Liquid
    module Tags
      module Csrf

        class Param < ::Liquid::Tag
          def render(context)
            controller  = context.registers[:controller]
            name        = controller.send(:request_forgery_protection_token).to_s
            value       = controller.send(:form_authenticity_token)
            %(<input type="hidden" name="#{name}" value="#{value}">)
          end
        end

        class Meta < ::Liquid::Tag
          def render(context)
            controller  = context.registers[:controller]
            name        = controller.send(:request_forgery_protection_token).to_s
            value       = controller.send(:form_authenticity_token)
            %{<meta name="csrf-param" content="#{name}">\n} +
            %{<meta name="csrf-token" content="#{value}">}
          end
        end
      end
      ::Liquid::Template.register_tag('csrf_param', Csrf::Param)
      ::Liquid::Template.register_tag('csrf_meta_tag', Csrf::Meta)
      ::Liquid::Template.register_tag('csrf_meta_tags', Csrf::Meta)
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
smithycms-0.8.1 lib/smithy/liquid/tags/csrf.rb
smithycms-0.7.3 lib/smithy/liquid/tags/csrf.rb
smithycms-0.7.2 lib/smithy/liquid/tags/csrf.rb
smithycms-0.7.1 lib/smithy/liquid/tags/csrf.rb
smithycms-0.7.0 lib/smithy/liquid/tags/csrf.rb
smithycms-0.6.10 lib/smithy/liquid/tags/csrf.rb
smithycms-0.5.99.3 lib/smithy/liquid/tags/csrf.rb
smithycms-0.6.9 lib/smithy/liquid/tags/csrf.rb
smithycms-0.6.7 lib/smithy/liquid/tags/csrf.rb
smithycms-0.6.6 lib/smithy/liquid/tags/csrf.rb
smithycms-0.6.5 lib/smithy/liquid/tags/csrf.rb
smithycms-0.6.4 lib/smithy/liquid/tags/csrf.rb
smithycms-0.6.3 lib/smithy/liquid/tags/csrf.rb
smithycms-0.5.99.2 lib/smithy/liquid/tags/csrf.rb
smithycms-0.5.99.1 lib/smithy/liquid/tags/csrf.rb
smithycms-0.5.99 lib/smithy/liquid/tags/csrf.rb
smithycms-0.6.2 lib/smithy/liquid/tags/csrf.rb
smithycms-0.6.1 lib/smithy/liquid/tags/csrf.rb
smithycms-0.5.2 lib/smithy/liquid/tags/csrf.rb
smithycms-0.6.0 lib/smithy/liquid/tags/csrf.rb