0

I am facing an issue with Auth, I have admin middleware and handle function inside, but Auth::check always return false. Seems like user session doesn't exist.

I thought the problem was in permissions for /storage and /bootstrap/cache, but when I set up 777 for these folders the problem still the same. Session folder is not empty.

I have tried to clear cache.

My Admin Middleware:

public function handle($request, Closure $next)
{
    //check the proper role
    if (Auth::check() && Auth::user()->isAdmin()) {
        return $next($request);
    }
    else {
        return response()->view('auth.forbidden')->header('Content-Type', 'text/html');
    }
}

Any Ideas?

Thanks

Zayn Ali
  • 4,765
  • 1
  • 30
  • 40
zm_fans
  • 101
  • 4

1 Answers1

0

alternatively you can use something like

//check the proper role
    $user = $request->user();
    if ($user && $user->isAdmin()) {
        return $next($request);
    }
    else {
        return response()->view('auth.forbidden')->header('Content-Type', 'text/html');
    }

will work is user is logged in and isAdmin

Saad Bhutto
  • 594
  • 1
  • 8
  • 22