hasAppAccess()) { if ($request->ajax()) { return response('Unauthorized.', 401); } return redirect()->guest(url('/login')); } return $next($request); } }