From 48c750db0d89685244e34b24a7f09dba9ebc8148 Mon Sep 17 00:00:00 2001 From: Web-serfer Date: Thu, 7 May 2026 20:10:34 +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=20=D1=81=D0=B0=D0=B9=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/layout/header/Header.astro | 3 +++ frontend/src/components/layout/header/UserMenu.astro | 5 ++++- frontend/src/pages/api/auth/sign-out.ts | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/layout/header/Header.astro b/frontend/src/components/layout/header/Header.astro index 4671194..26ffb53 100644 --- a/frontend/src/components/layout/header/Header.astro +++ b/frontend/src/components/layout/header/Header.astro @@ -520,9 +520,12 @@ import { COMPANY } from "@constants"; try { await fetch('/api/auth/logout', { method: 'POST' }); } catch (e) {} + // Очищаем localStorage localStorage.removeItem('auth_token'); localStorage.removeItem('user'); localStorage.removeItem('pocketbase_auth'); + // Удаляем cookie pb_auth + document.cookie = 'pb_auth=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT'; document.querySelector('.header-right')?.classList.remove('auth-active'); window.location.reload(); }); diff --git a/frontend/src/components/layout/header/UserMenu.astro b/frontend/src/components/layout/header/UserMenu.astro index baf7063..975b7a2 100644 --- a/frontend/src/components/layout/header/UserMenu.astro +++ b/frontend/src/components/layout/header/UserMenu.astro @@ -112,7 +112,10 @@ const firstLetter = userName ? userName.charAt(0).toUpperCase() : userEmail?.cha localStorage.removeItem('user'); localStorage.removeItem('pocketbase_auth'); - // Полностью перезагружаем страницу — SSR проверит куки и обновит состояние + // Удаляем cookie pb_auth + document.cookie = 'pb_auth=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT'; + + // Полностью перезагружаем страницу window.location.reload(); }); }); diff --git a/frontend/src/pages/api/auth/sign-out.ts b/frontend/src/pages/api/auth/sign-out.ts index 18de29e..18edac7 100644 --- a/frontend/src/pages/api/auth/sign-out.ts +++ b/frontend/src/pages/api/auth/sign-out.ts @@ -12,8 +12,8 @@ export const POST: APIRoute = async ({ cookies }) => { status: 200, headers: { 'Content-Type': 'application/json', - // Принудительно удаляем куку на клиенте - 'Set-Cookie': 'pb_auth=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT', + // Принудительно удаляем куку на клиенте - два варианта для надежности + 'Set-Cookie': 'pb_auth=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT', } }); }; \ No newline at end of file