I'm using the features offered by laravel for authentication, but even if I logged on the auth :: guest () command returns true as if it were a guest.
Follow the code for my middleware
<?php
namespace App\Http\Middleware;
use Closure;
use Auth;
class Autorizacao
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(!$request->is('/') && !$request->is('home') && !$request->is('login') && !$request->is('logout') && !$request->is('register') && Auth::guest()){
if(Auth::guest())
echo 'true';
else
echo 'false';
//return redirect('/login');
}
return $next($request);
}
}
I did not use dd () because it terminates the process to display the result, and may not log in.
In this case I would like the login screen to be displayed if the user was not logged in, but could access the routes for login / logout or home, but if logged in would have access to all the screens.