diff --git a/app/controllers/api/products_controller.rb b/app/controllers/api/products_controller.rb index 13abb37ff5..fa41d186e4 100644 --- a/app/controllers/api/products_controller.rb +++ b/app/controllers/api/products_controller.rb @@ -94,10 +94,13 @@ module Api private - # Copied and modified from SpreeApi::BaseController to allow - # enterprise users to access inactive products + def find_product(id) + product_scope.find_by_permalink!(id.to_s) + rescue ActiveRecord::RecordNotFound + product_scope.find(id) + end + def product_scope - # This line modified if current_api_user.has_spree_role?("admin") || current_api_user.enterprises.present? scope = Spree::Product if params[:show_deleted] diff --git a/app/controllers/spree/api/base_controller.rb b/app/controllers/spree/api/base_controller.rb index c201128bf2..7d6e84d67b 100644 --- a/app/controllers/spree/api/base_controller.rb +++ b/app/controllers/spree/api/base_controller.rb @@ -69,25 +69,6 @@ module Spree request.headers["X-Spree-Token"] || params[:token] end helper_method :api_key - - def find_product(id) - product_scope.find_by_permalink!(id.to_s) - rescue ActiveRecord::RecordNotFound - product_scope.find(id) - end - - def product_scope - if current_api_user.has_spree_role?("admin") - scope = Product - if params[:show_deleted] - scope = scope.with_deleted - end - else - scope = Product.active - end - - scope.includes(:master) - end end end end