Hello @azim1728
Do you get redirected to the same page or between multiple pages? That can make a different where you need to check it :)
Small sidenote, you can get the user with $request->user();
Hey @tvbeek ,
I get redirected to the same page even if I am on that particular page.
Thanks for your sidenote.
I see 2 possible reasons:
$request->route()->getName()
result in another name then any name in the array. You could check it with a dd() in the if statement.Example:
public function handle(Request $request, Closure $next): Response
{
$user = auth()->user();
if ($user && $user->passwordChangedAt === null && !$this->shouldExcludeRoute($request)) {
dd('name mismatch', $request->route()->getName(),);
return redirect()->route('nova.pages.password.email');
}
dd('we execute next, that means the problem is not in this middleware.');
return $next($request);
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community