From 76a9d4c1b34bc098d0d4f754d20ddbf4c3599af9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 19 May 2026 14:27:20 +0300 Subject: [PATCH] fix: auto-logout on 401 so stale tokens don't leave frontend in broken state Co-Authored-By: Claude Sonnet 4.6 --- frontend/app.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/app.js b/frontend/app.js index a90db2d..0734fcd 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -150,9 +150,7 @@ createApp({ this.users = []; this.status = ''; this.error = ''; - this.view = 'byAud'; - // опционально: редирект на страницу логина - // window.location.href = '/login'; + window.location.href = '/login'; }, authHeaders() { const h = {}; @@ -162,6 +160,10 @@ createApp({ async fetchAuth(url, options = {}) { const opt = { ...options, headers: { ...(options.headers||{}), ...this.authHeaders() } }; const res = await fetch(url, opt); + if (res.status === 401) { + this.logout(); + return; + } if (!res.ok) { const text = await res.text(); throw new Error(`HTTP ${res.status}: ${text}`);