diff --git a/lib/spree/auth/engine.rb b/lib/spree/auth/engine.rb index 0c2aa82..2573e30 100644 --- a/lib/spree/auth/engine.rb +++ b/lib/spree/auth/engine.rb @@ -21,10 +21,19 @@ class Engine < Rails::Engine Spree::Auth::Config = Spree::AuthConfiguration.new end - config.to_prepare do - Spree::Auth::Engine.prepare_backend if SolidusSupport.backend_available? - Spree::Auth::Engine.prepare_frontend if SolidusSupport.frontend_available? + if Spree::Config.respond_to?(:unauthorized_redirect_handler_class) + Spree::Config.unauthorized_redirect_handler_class = "Spree::Auth::UnauthorizedCustomerAccessHandler" + if SolidusSupport.backend_available? + Spree::Backend::Config.unauthorized_redirect_handler_class = "Spree::Auth::UnauthorizedAdminAccessHandler" + end + else + config.to_prepare do + Spree::Auth::Engine.prepare_backend if SolidusSupport.backend_available? + Spree::Auth::Engine.prepare_frontend if SolidusSupport.frontend_available? + end + end + config.to_prepare do ApplicationController.include Spree::AuthenticationHelpers end