How to properly integrate middleware without ending up in a "TOO MANY REDIRECTS" issue

I'm validating the user->is_profile_complete column, then force redirect user to "Complete profile wizard" page, but ending up on too many redirects error
Solution:
So you need to exclude that route from your middleware
Jump to solution
5 Replies
Dennis Koch
Dennis Koch2y ago
Show some code.
dansing
dansingOP2y ago
Panel: ->authMiddleware([ Authenticate::class, EnsureEmailIsVerified::class, EnsureProfileIsCompleted::class ]); middleware /** * Handle an incoming request. * * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next */ public function handle(Request $request, Closure $next): Response { if ($request->user()->hasRole(['Admin'])) return $next($request); $account = $request->user()->account; if ($account && (! $account->master_profile || ! $account->master_profile->isProfileCompleted())) { return $request->expectsJson() ? abort(403, 'Some error message') : redirect(route('filament.app.resources.users.edit-profile', $request->user())); } return $next($request); } @Dennis Koch added codes I used
Dennis Koch
Dennis Koch2y ago
Your Profile page is also Filament, right? So it's affected by the middelware too
dansing
dansingOP2y ago
Yes, it's a Filament too
Solution
Dennis Koch
Dennis Koch2y ago
So you need to exclude that route from your middleware

Did you find this page helpful?