Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
When trying to access Admin and Admin login is available redirect to Admin Login
Damian Legawiec90321a8338fa
diff --git a/core/lib/spree/core/controller_helpers/auth.rb b/core/lib/spree/core/controller_helpers/auth.rbindex f47f38bb26..12df3d074e 100644--- a/core/lib/spree/core/controller_helpers/auth.rb+++ b/core/lib/spree/core/controller_helpers/auth.rb@@ -76,7 +76,9 @@ module Spreeredirect_to spree.forbidden_pathelsestore_location- if respond_to?(:spree_login_path)+ if request.fullpath.match(Spree.admin_path) && defined?(spree.admin_login_path)+ redirect_to spree.admin_login_path+ elsif respond_to?(:spree_login_path)redirect_to spree_login_pathelsif spree.respond_to?(:root_path)redirect_to spree.root_pathdiff --git a/core/spec/lib/spree/core/controller_helpers/auth_spec.rb b/core/spec/lib/spree/core/controller_helpers/auth_spec.rbindex 6db87bf588..799dfa7db6 100644--- a/core/spec/lib/spree/core/controller_helpers/auth_spec.rb+++ b/core/spec/lib/spree/core/controller_helpers/auth_spec.rb@@ -106,6 +106,14 @@ describe Spree::Core::ControllerHelpers::Auth, type: :controller doget :indexexpect(response).to redirect_to('/login')end++ it 'redirects admin login path when admin controller' do+ allow(controller).to receive_message_chain(:spree, :admin_login_path).and_return('/admin/login')+ allow_any_instance_of(ActionController::TestRequest).to receive(:fullpath).and_return('http://test.host/admin/fakes')+ get :index+ expect(response).to redirect_to('/admin/login')+ end+it 'redirects root path' doallow(controller).to receive_message_chain(:spree, :root_path).and_return('/root_path')get :index