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(); +}