Fixed isLoggedIn check

This commit is contained in:
WardPearce
2026-02-14 16:27:53 +13:00
parent a1efe412ee
commit 94512f1521
2 changed files with 13 additions and 8 deletions
+10 -8
View File
@@ -191,13 +191,13 @@
async function logout() {
if (isYTBackend()) {
await clearFeedYTjs();
if (isOwnBackend()?.internalAuth) {
rawMasterKeyStore.set(undefined);
fetch('/api/user/logout', { method: 'DELETE' });
}
}
if (isOwnBackend()?.internalAuth) {
fetch('/api/user/logout', { method: 'DELETE' });
}
rawMasterKeyStore.set(undefined);
authStore.set(null);
goto(resolve('/', {}));
}
@@ -260,9 +260,11 @@
}
if ($rawMasterKeyStore) {
fetch('/api/user/isLoggedIn', { method: 'GET', credentials: 'same-origin' }).catch(() => {
logout();
});
fetch('/api/user/isLoggedIn', { method: 'GET', credentials: 'same-origin' })
.then((resp) => {
if (!resp.ok) logout();
})
.catch(logout);
}
resetScroll();
@@ -1,3 +1,4 @@
import { getUser } from '$lib/server/user.js';
import { error } from '@sveltejs/kit';
export async function GET({ locals }) {
@@ -5,5 +6,7 @@ export async function GET({ locals }) {
throw error(401);
}
await getUser(locals.userId);
return new Response();
}