fix: auto-logout on WS auth.error (forces re-login with valid JWT)

This commit is contained in:
Markov 2026-02-24 09:38:31 +01:00
parent 3a2a32a50e
commit f9d0bfd3a3

View File

@ -51,6 +51,14 @@ class WSClient {
this.pendingQueue = []; this.pendingQueue = [];
} }
// Auth error → force re-login
if (type === "auth.error") {
console.error("WS auth failed:", msg);
localStorage.removeItem("tb_token");
window.location.href = "/login";
return;
}
// Dispatch to handlers // Dispatch to handlers
const fns = this.handlers.get(type); const fns = this.handlers.get(type);
if (fns) fns.forEach((fn) => fn(msg.data || msg)); if (fns) fns.forEach((fn) => fn(msg.data || msg));