Новые правки сайта

This commit is contained in:
Web-serfer 2026-05-07 20:10:34 +05:00
parent cd8da6b3b8
commit 48c750db0d
3 changed files with 9 additions and 3 deletions

View file

@ -520,9 +520,12 @@ import { COMPANY } from "@constants";
try { try {
await fetch('/api/auth/logout', { method: 'POST' }); await fetch('/api/auth/logout', { method: 'POST' });
} catch (e) {} } catch (e) {}
// Очищаем localStorage
localStorage.removeItem('auth_token'); localStorage.removeItem('auth_token');
localStorage.removeItem('user'); localStorage.removeItem('user');
localStorage.removeItem('pocketbase_auth'); 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'); document.querySelector('.header-right')?.classList.remove('auth-active');
window.location.reload(); window.location.reload();
}); });

View file

@ -112,7 +112,10 @@ const firstLetter = userName ? userName.charAt(0).toUpperCase() : userEmail?.cha
localStorage.removeItem('user'); localStorage.removeItem('user');
localStorage.removeItem('pocketbase_auth'); 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(); window.location.reload();
}); });
}); });

View file

@ -12,8 +12,8 @@ export const POST: APIRoute = async ({ cookies }) => {
status: 200, status: 200,
headers: { headers: {
'Content-Type': 'application/json', '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',
} }
}); });
}; };