Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 942e1c1

Browse files
committedDec 21, 2024·
Use Solidus 4.4 Redirect extension points if available
This makes the `prepare_{frontend,backend}` methods which instantiate the base controller and the admin base controller, requiring all of ActionController::Base, unnecessary to call for newer Solidus versions. Depends on solidusio/solidus#6051
1 parent a0aa283 commit 942e1c1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
 

‎lib/spree/auth/engine.rb

+12-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,19 @@ class Engine < Rails::Engine
2121
Spree::Auth::Config = Spree::AuthConfiguration.new
2222
end
2323

24-
config.to_prepare do
25-
Spree::Auth::Engine.prepare_backend if SolidusSupport.backend_available?
26-
Spree::Auth::Engine.prepare_frontend if SolidusSupport.frontend_available?
24+
if Spree::Config.respond_to?(:unauthorized_redirect_handler_class)
25+
Spree::Config.unauthorized_redirect_handler_class = "Spree::Auth::UnauthorizedCustomerAccessHandler"
26+
if SolidusSupport.backend_available?
27+
Spree::Backend::Config.unauthorized_redirect_handler_class = "Spree::Auth::UnauthorizedAdminAccessHandler"
28+
end
29+
else
30+
config.to_prepare do
31+
Spree::Auth::Engine.prepare_backend if SolidusSupport.backend_available?
32+
Spree::Auth::Engine.prepare_frontend if SolidusSupport.frontend_available?
33+
end
34+
end
2735

36+
config.to_prepare do
2837
ApplicationController.include Spree::AuthenticationHelpers
2938
end
3039

0 commit comments

Comments
 (0)
Please sign in to comment.