Skip to content

Commit

Permalink
Use Solidus 4.4 Redirect extension points if available
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mamhoff committed Dec 21, 2024
1 parent fad97b8 commit 79f443c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/spree/auth/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 79f443c

Please sign in to comment.