0
I have a system with the following routes
- '\'
- '\expenses'
- '\Register'
- '\login'
- '\home'
of these routes would like to make available only for user NOT authenticated ' ' 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 login page. This worked for Registry, but when accessing expenses I can access even if I am not authenticated.
public function handle($request, Closure $next, $guard = null)
{
if (!$request->is('login') && Auth::guard($guard)) {
return redirect('/home');
}
return $next($request);
}
Can’t I do the opposite? group the routes do not want authenticate, otherwise authenticate the others, or I have to spectrify only the routes that need authentication?
– Alexandre Vieira de Souza
You can also, there just make the opposite condition of what I put in the middleware in the answer above, ai creates as guest and groups these routes in this Middleware
– arllondias