generated from filamentphp/plugin-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
Hi! Should we use this registration
$panel->middleware([
config('password-expiry.password_expiry_middleware', PasswordExpiryMiddleware::class),
]);
instead of
$panel->middleware([
PasswordExpiryMiddleware::class
]);
and also should we pass jsonresponses through the middleware as in the example
public function handle(Request $request, Closure $next): Response | RedirectResponse
{
if (
$this->passwordHasExpired() &&
!$request->routeIs(PasswordExpiry::getPasswordExpiryRoute()) &&
!$request->routeIs('*.auth.*')
) {
return redirect(route(PasswordExpiry::getPasswordExpiryRoute()));
}
$response = $next($request);
if ($response instanceof JsonResponse) {
return response($response->getContent(), $response->getStatusCode(), $response->headers->all());
}
return $response;
}
instead of
public function handle(Request $request, Closure $next): Response | RedirectResponse
{
if (
$this->passwordHasExpired() &&
!$request->routeIs(PasswordExpiry::getPasswordExpiryRoute()) &&
!$request->routeIs('*.auth.*')
) {
return redirect(route(PasswordExpiry::getPasswordExpiryRoute()));
}
return $next($request);
}
?
Currently I have a problem that middleware in my plugin does not work. But when I use the proposed registration, it works.
How to reproduce the bug
You should try to set custom class in config + try to pass JsonResponse through the middleware
Package Version
3.0
PHP Version
8.3
Laravel Version
11.0
Which operating systems does with happen with?
No response
Notes
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working