From 51efcbd00ac9041b80d4d98a5d4d0b994dbfc367 Mon Sep 17 00:00:00 2001 From: Web-serfer Date: Thu, 7 May 2026 18:50:53 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/layout/header/MobileMenu.astro | 6 ++---- frontend/src/components/layout/header/UserMenu.astro | 6 ++---- frontend/src/pages/blog/[slug].astro | 12 ++---------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/frontend/src/components/layout/header/MobileMenu.astro b/frontend/src/components/layout/header/MobileMenu.astro index b179566..3c84e31 100644 --- a/frontend/src/components/layout/header/MobileMenu.astro +++ b/frontend/src/components/layout/header/MobileMenu.astro @@ -584,10 +584,8 @@ import { NAV_LINKS, COMPANY } from '@constants'; localStorage.removeItem('user'); localStorage.removeItem('pocketbase_auth'); - // Через 3 сек возвращаем кнопку входа - setTimeout(() => { - restoreLoginButton(); - }, 3000); + // Полностью перезагружаем страницу — SSR проверит куки и обновит состояние + window.location.reload(); }; }; diff --git a/frontend/src/components/layout/header/UserMenu.astro b/frontend/src/components/layout/header/UserMenu.astro index 53ea5a3..baf7063 100644 --- a/frontend/src/components/layout/header/UserMenu.astro +++ b/frontend/src/components/layout/header/UserMenu.astro @@ -112,10 +112,8 @@ const firstLetter = userName ? userName.charAt(0).toUpperCase() : userEmail?.cha localStorage.removeItem('user'); localStorage.removeItem('pocketbase_auth'); - // Перенаправляем на текущую страницу с параметром loggedout - const currentUrl = window.location.pathname + window.location.search + window.location.hash; - const separator = currentUrl.includes('?') ? '&' : '?'; - window.location.href = currentUrl + separator + 'loggedout=true'; + // Полностью перезагружаем страницу — SSR проверит куки и обновит состояние + window.location.reload(); }); }); \ No newline at end of file diff --git a/frontend/src/pages/blog/[slug].astro b/frontend/src/pages/blog/[slug].astro index bfe20ac..68aa2ee 100644 --- a/frontend/src/pages/blog/[slug].astro +++ b/frontend/src/pages/blog/[slug].astro @@ -23,17 +23,13 @@ if (!post) { return Astro.redirect('/blog'); } -// SSR проверка авторизации - используем реальную проверку через API +// SSR проверка авторизации let isAuthorized = false; const pbAuthCookie = Astro.cookies.get('pb_auth')?.value; -console.log('[SSR] Cookie exists:', !!pbAuthCookie); - if (pbAuthCookie && PB_POCKETBASE_URL && PB_POCKETBASE_URL.startsWith('http')) { try { const token = pbAuthCookie.trim(); - - console.log('[SSR] Token preview:', token.substring(0, 20) + '...'); const response = await fetch(`${PB_POCKETBASE_URL}/api/collections/users/auth-refresh`, { method: 'POST', @@ -43,18 +39,14 @@ if (pbAuthCookie && PB_POCKETBASE_URL && PB_POCKETBASE_URL.startsWith('http')) { }, }); - console.log('[SSR] PB response:', response.status); - if (response.ok) { const data = await response.json(); - console.log('[SSR] Auth valid, user:', data.record?.email); isAuthorized = true; } else { - console.log('[SSR] Auth invalid, deleting cookie'); Astro.cookies.delete('pb_auth', { path: '/' }); } } catch (e) { - console.error('[SSR] Error:', e.message); + console.error('[SSR] Auth check error:', e.message); } }