Files
clinicpro/templates/maintenance.html.twig
hamedandClaude Fable 5 7ac8ddbd25 feat(config): add central maintenance mode
Adds a platform-wide maintenance switch controlled from the admin panel.
A single kernel.request subscriber (priority 6, after the firewall listener)
short-circuits every request with 503, so no controller has to check it and
all API clients — the admin SPA, nobat724_front and clinic-pro-tauri — are
covered at once.

- SiteConfig gains five maintenance_* keys; no entity change, no migration
- MaintenanceService caches the state in Redis for 30s and is fail-open:
  a Redis or database failure never takes the site down by itself
- API responses reuse the BaseController::error() envelope with code
  MAINTENANCE_MODE plus a Retry-After header; browsers get a self-contained
  Twig page (inline CSS, noindex) that renders even mid-deploy
- Whitelist keeps /oauth/*, the login endpoints and /api/v1/admin/settings
  reachable, otherwise an admin could neither sign in nor switch it back off
- Admin bypass falls back to decoding the Authorization JWT, because several
  admin-panel endpoints sit in the public_endpoints firewall (security: false)
  where no token is ever resolved and isGranted always returns false
- A kernel.exception handler at priority 20 covers routing 404/405 and
  firewall 401, which are thrown before the request listener runs
- app:maintenance on|off|status is the escape hatch when the panel is down

Also removes a stray `APP_SECRET = ...` line from .env.dev: the spaces around
`=` are rejected by Symfony Dotenv, which made every console command and the
whole app fatal. The secret already lives in .env.local, as the comment above
that line instructs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 22:01:34 +03:30

88 lines
2.8 KiB
Twig

<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<title>{{ title }}</title>
{# استایل عمداً inline است: این صفحه ممکن است حین deploy و پیش از build اسِت‌ها رندر شود. #}
<style>
:root {
--primary: #5559CE;
--bg: #f6f7fb;
--surface: #ffffff;
--text: #1f2233;
--text-2: #5b6076;
--border: #e4e6f0;
}
* { box-sizing: border-box; }
body {
margin: 0;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
background: var(--bg);
color: var(--text);
font-family: "Vazirmatn", "Vazir", Tahoma, sans-serif;
}
.card {
width: 100%;
max-width: 520px;
padding: 40px 32px;
text-align: center;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 18px;
box-shadow: 0 12px 32px rgba(31, 34, 51, .08);
}
.icon {
width: 72px;
height: 72px;
margin: 0 auto 24px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 999px;
background: rgba(85, 89, 206, .1);
color: var(--primary);
}
h1 { margin: 0 0 12px; font-size: 22px; font-weight: 700; }
p { margin: 0; font-size: 15px; line-height: 2; color: var(--text-2); }
.retry {
display: inline-block;
margin-top: 28px;
padding: 10px 28px;
border-radius: 999px;
background: var(--primary);
color: #fff;
font-size: 14px;
text-decoration: none;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #14161f;
--surface: #1c1f2b;
--text: #eef0f7;
--text-2: #a2a7bd;
--border: #2a2e3d;
}
}
</style>
</head>
<body>
<main class="card">
<div class="icon">
<svg width="34" height="34" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="12" cy="12" r="9"></circle>
<path d="M12 7v5l3 2"></path>
</svg>
</div>
<h1>{{ title }}</h1>
<p>{{ message }}</p>
<a class="retry" href="{{ app.request.requestUri }}">تلاش مجدد</a>
</main>
</body>
</html>