is(...self::ALWAYS_ALLOWED) || Settings::bool('site.public', true)) { return $next($request); } if ($this->fromManagementNetwork($request) || $this->isActiveOperator()) { return $next($request); } return response()->view('coming-soon', [], 503)->withHeaders([ 'Retry-After' => 3600, 'X-Robots-Tag' => 'noindex, nofollow, noarchive', 'Cache-Control' => 'no-store', ]); } private function fromManagementNetwork(Request $request): bool { $ranges = (array) config('admin_access.trusted_ranges', []); return $ranges !== [] && IpUtils::checkIp((string) $request->ip(), $ranges); } /** * Same standard as EnsureAdmin: an active operator holding a console role. * A bare `check()` stays true for a disabled operator's live session — * disabling someone did not sign them out, so it never stopped this gate * from waving them through indefinitely. * * Deliberately checked, not enforced by logging out: this gate only * decides what ONE request sees, and destroying the session would ripple * into whatever else that session is doing (a concurrent console tab, * mid-task) — a much bigger side effect than a visibility check exists to * have. EnsureAdmin sets the precedent: it also 403s a disabled operator * per request without touching their session. */ private function isActiveOperator(): bool { $operator = Auth::guard('operator')->user(); return $operator !== null && $operator->isActive() && $operator->can('console.view'); } }