Sha256: 39a8428abc371031d85ec78dea012ceae09180e1c8478228e4386f899b49b311

Contents?: true

Size: 507 Bytes

Versions: 13

Compression:

Stored size: 507 Bytes

Contents

module VerifyCsrfToken
  extend ActiveSupport::Concern

  included do
    before_action :set_csrf_cookie

    rescue_from ActionController::InvalidAuthenticityToken do
      redirect_back fallback_location: '/', notice: 'The page expired, please try again.'
    end
  end

  def request_authenticity_tokens
    super << request.headers['HTTP_X_XSRF_TOKEN']
  end

  private

  def set_csrf_cookie
    cookies['XSRF-TOKEN'] = {
      value: form_authenticity_token,
      same_site: 'Strict'
    }
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
kaze-0.17.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
kaze-0.16.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
kaze-0.15.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
kaze-0.14.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
kaze-0.13.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
kaze-0.12.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
kaze-0.11.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
kaze-0.10.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
kaze-0.9.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
kaze-0.8.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
kaze-0.7.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
kaze-0.6.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
kaze-0.5.0 stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb