From d21b1a5f51d36298e65a1642e961763dc5c44dd3 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 2 Sep 2026 09:43:33 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20401:=20force=20logout=20si=20token=20expi?= =?UTF-8?q?r=C3=A9=20(Dashboard)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.jsx | 2 +- frontend/src/components/Dashboard.jsx | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 745a8ae..b935790 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -27,7 +27,7 @@ function App() { - } /> + } /> } /> diff --git a/frontend/src/components/Dashboard.jsx b/frontend/src/components/Dashboard.jsx index d37f867..6320251 100644 --- a/frontend/src/components/Dashboard.jsx +++ b/frontend/src/components/Dashboard.jsx @@ -14,7 +14,7 @@ function getCosts(d) { return { nbUsers, doms, ksuite, site, extra, domCost, total: ksuite + site + extra + domCost } } -export default function Dashboard({ token, user }) { +export default function Dashboard({ token, user, onLogout }) { const [domains, setDomains] = useState([]) const [activeTab, setActiveTab] = useState(-1) const [loading, setLoading] = useState(true) @@ -23,7 +23,12 @@ export default function Dashboard({ token, user }) { useEffect(() => { fetch('/api/domains', { headers: { Authorization: 'Bearer ' + token } }) - .then(r => r.json()).then(d => { + .then(r => { + if (r.status === 401) { onLogout && onLogout(); return null } + return r.json() + }) + .then(d => { + if (!d) return const all = d.parent ? [d.parent, ...d.children] : d.children setDomains(all) setLoading(false)