fix(middlewares): handle guest and auth redirects correctly
Ensure that both guest and authenticated user redirects are processed properly.
This commit is contained in:
parent
341a66a2d1
commit
bd314a4575
1 changed files with 11 additions and 5 deletions
|
|
@ -44,11 +44,17 @@ $redirectUsers = function (Request $request) {
|
|||
'backend' => route('bo.dashboard'),
|
||||
'frontend' => route('fo.pages.home'),
|
||||
];
|
||||
foreach ($request->route()->gatherMiddleware() as $middleware) {
|
||||
if (\is_string($middleware) && str_contains($middleware, 'auth:')) {
|
||||
$route = $logins[str_replace('auth:', '', $middleware)] ?? null;
|
||||
if ($route) {
|
||||
return $route;
|
||||
foreach ($request->route()?->gatherMiddleware() ?? [] as $middleware) {
|
||||
if (! \is_string($middleware)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (['auth:', 'guest:'] as $prefix) {
|
||||
if (str_starts_with($middleware, $prefix)) {
|
||||
$route = $logins[substr($middleware, strlen($prefix))] ?? null;
|
||||
if ($route) {
|
||||
return $route;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue