framework\exceptions\Handler::unauthenticated PHP Method

unauthenticated() protected method

Convert an authentication exception into an unauthenticated response.
protected unauthenticated ( Illuminate\Http\Request $request, Illuminate\Auth\AuthenticationException $exception ) : Illuminate\Http\Response
$request Illuminate\Http\Request
$exception Illuminate\Auth\AuthenticationException
return Illuminate\Http\Response
    protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['error' => 'Unauthenticated.'], 401);
        }
        return redirect()->guest('login');
    }