-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unauthorized redirect handling config #6051
Unauthorized redirect handling config #6051
Conversation
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
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
f24f2ae
to
7753b24
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mamhoff! I think there are some failing specs because we're modifying global configuration in one of the specs added, but otherwise this change looks great and it'll make overriding this behaviour much easier on stores that require more granular permissions.
c259ad3
to
cc0a2eb
Compare
This lambda has to be set on the instantiated class, requiring the controller it's set on to be autoloaded on boot. Loading a controller also loads all helpers, and that takes quite a bit of time. So this comes with a performance benefit, because neither the controller nor the handler need to be loaded at configuration time.
The previous `unauthorized_redirect` can really only be set globally, but it's a common use case to handle unauthorized access differently for the admin. This adds a configuration option for the admin base controller, allowing customizers to set that behavior without having to patch any controller.
Customizers can now set their own unauthorized_redirect class with any behavior from the controller they might need. There's no need for this suggestion (and the comment is not entirely true either, as the handler provided does not re-raise the exception, but raises another one).
This make sure the admin also uses the configured redirect handler class.
cc0a2eb
to
8daded5
Compare
This change is VERY much appreciated 🚀 |
Summary
This replaces the
unauthorized_redirect
lambda that can be set on any controller with two configurable classes that are by default both set to the same defaultSpree::UnauthorizedRedirectHandler
. Two, because frontend and backend will require different strategies in many cases (not least in the case of thesolidus_auth_devise
extension).Care has been taken to maintain the legacy behavior and print out deprecation warnings.
A big part of the reason is that setting the lamda on the controllers requires loading the controllers, making us need to use a
config.to_prepare
block as well as making us inadvertently eager-load a lot of code.Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: