Sha256: 66c19f230469fb628f598d46821b954768eae1a4d101940f89f7b4c22f089a20

Contents?: true

Size: 480 Bytes

Versions: 2

Compression:

Stored size: 480 Bytes

Contents

Spree::ProductsController.class_eval do
  rescue_from CanCan::AccessDenied, :with => :render_404

  private
    def load_product
      @product = Spree::Product.find_by_permalink!(params[:id])
      if !@product.deleted? && (@product.available_on.nil? || @product.available_on.future?)
        # Allow admins to view any yet to be available products
        raise CanCan::AccessDenied unless spree_current_user && spree_current_user.has_spree_role?(:admin)
      end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_auth_devise-1.0.1 app/controllers/spree/products_controller_decorator.rb
spree_auth_devise-1.0.0 app/controllers/spree/products_controller_decorator.rb