[4.0][Idea] Allow for guard specific routes
ollieread opened this issue · 0 comments
ollieread commented
The idea is that instead of adding auth:admin
or guest:admin
everywhere, you could specify it on the router. This would also affect the user resolver present on the Request object, as that isn't pretty either.
This does sort of couple authentication and routes, but they are inherently coupled anyway.
There are a few options.
Option 1
This would lock in a group as a particular guard, so just auth
or guest
middleware could be used.
$router->guard('admin')->group(function (Router $router) {
// Routes here
});
Option 2
Instead of locking in a group, add two new methods for specifically providing guest or auth routes. This would translate internally to a group with the correct middleware, so would just be a pass-through method.
$router->guest('admin', function (Router $router) {
// Routes here
});
$router->auth('admin', function (Router $router) {
// Routes here
});
Option 3
This is a combination of Option 1 and Option 2.
$router->guard('admin', function (Router $router) {
// Guest routes here
}, function (Router $router) {
// Auth routes here
});