From 83596959946c42b9682ffc876bb69de616080d3c Mon Sep 17 00:00:00 2001 From: WardPearce Date: Sat, 14 Feb 2026 04:17:22 +1300 Subject: [PATCH] Added check for if login cookie expires --- materialious/src/routes/(app)/+layout.svelte | 8 +++++++- materialious/src/routes/api/user/isLoggedIn/+server.ts | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 materialious/src/routes/api/user/isLoggedIn/+server.ts diff --git a/materialious/src/routes/(app)/+layout.svelte b/materialious/src/routes/(app)/+layout.svelte index 30a6f769..f65d74e9 100644 --- a/materialious/src/routes/(app)/+layout.svelte +++ b/materialious/src/routes/(app)/+layout.svelte @@ -256,7 +256,13 @@ setAmoledTheme(); if (isLoggedIn && !isYTBackend()) { - loadNotifications().catch(() => authStore.set(null)); + loadNotifications().catch(() => logout()); + } + + if ($rawMasterKeyStore) { + fetch('/api/user/isLoggedIn', { method: 'GET', credentials: 'same-origin' }).catch(() => { + logout(); + }); } resetScroll(); diff --git a/materialious/src/routes/api/user/isLoggedIn/+server.ts b/materialious/src/routes/api/user/isLoggedIn/+server.ts new file mode 100644 index 00000000..cef444e0 --- /dev/null +++ b/materialious/src/routes/api/user/isLoggedIn/+server.ts @@ -0,0 +1,9 @@ +import { error } from '@sveltejs/kit'; + +export async function GET({ locals }) { + if (!locals.userId) { + throw error(401); + } + + return new Response(); +}