Support the ongoing development of →
Nova Laravel

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:

  1. $request->route()->getName() result in another name then any name in the array. You could check it with a dd() in the if statement.
  2. There is another middleware that result in a new redirect, you could check it with a dd() before the next to see if you are there.


    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('');
        dd('we execute next, that means the problem is not in this middleware.');
        return $next($request);

Sign in to participate in this thread!


Your banner here too?

Azim Belim azim1728 Joined 14 Mar 2023


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.