F
Filament13mo ago
lodeki

Middleware redirect will never complete.

I have created a middlware that redirects user based on if they are verified like this
public function handle(Request $request, Closure $next): Response
{
$user = Auth::user();
if ($user != null) {
if (!$user->is_verified) {
return redirect('verify');
}
}
return $next($request);
}
public function handle(Request $request, Closure $next): Response
{
$user = Auth::user();
if ($user != null) {
if (!$user->is_verified) {
return redirect('verify');
}
}
return $next($request);
}
. and this is my middleware list in the panel provider
middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
MyMiddleware:class,
])
middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
MyMiddleware:class,
])
However i face this error on the browser Firefox has detected that the server is redirecting the request for this address in a way that will never complete.. Any idea why ? tried to clear the cookies , caches but still the same .Tried also on another browser but still no success .
4 Replies
lodeki
lodekiOP13mo ago
Any idea here please?
ChesterS
ChesterS13mo ago
Maybe you need to check if you are in the verify page too, or else it will keep redirecting you? @lodeki BTW this is more of a laravel/php issue so you can ask there https://discord.com/invite/laravel
lodeki
lodekiOP13mo ago
And is my order of the middlewares in the provider okay.
Dennis Koch
Dennis Koch13mo ago
Yes. Chester already pointed out the issue.
Want results from more Discord servers?
Add your server