Sha256: def90f9e9716bbc5ce02ae34edea4707ae667bc91349c3a4a54552cd0360e41d
Contents?: true
Size: 963 Bytes
Versions: 3
Compression:
Stored size: 963 Bytes
Contents
# frozen_string_literal: true module SolidusAfterpay class BaseController < ::Spree::BaseController protect_from_forgery unless: -> { request.format.json? } rescue_from ::ActiveRecord::RecordNotFound, with: :resource_not_found rescue_from ::CanCan::AccessDenied, with: :unauthorized private def order_token cookies.signed[:guest_token] end def resource_not_found respond_to do |format| format.html { redirect_to spree.cart_path, notice: I18n.t('solidus_afterpay.resource_not_found') } format.json { render json: { error: I18n.t('solidus_afterpay.resource_not_found') }, status: :not_found } end end def unauthorized respond_to do |format| format.html { redirect_to spree.cart_path, notice: I18n.t('solidus_afterpay.unauthorized') } format.json { render json: { error: I18n.t('solidus_afterpay.unauthorized') }, status: :unauthorized } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems