I have a system with the following routes
of these routes would like to leave only unauthenticated user '\' and '\ login',
For this I changed the handle function of the RedirectIfAuthenticated class, so that when it is authenticated it is directed to home, otherwise go to the login page. This worked for register, but when access \ expenses I get access even though it is not authenticated.
public function handle($request, Closure $next, $guard = null)
{
if (!$request->is('login') && Auth::guard($guard)) {
return redirect('/home');
}
return $next($request);
}