From 6649dc303ed96ccaf7ee0e4d9e74d5d56ef814e8 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Mon, 9 Dec 2024 17:35:21 +0545 Subject: [PATCH] fix(+page): remove user details from localStorage in case of session expiration --- src/mapper/src/routes/[projectId]/+page.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mapper/src/routes/[projectId]/+page.ts b/src/mapper/src/routes/[projectId]/+page.ts index 3c1453d950..0b9d15b235 100644 --- a/src/mapper/src/routes/[projectId]/+page.ts +++ b/src/mapper/src/routes/[projectId]/+page.ts @@ -1,11 +1,13 @@ import { error } from '@sveltejs/kit'; import type { PageLoad } from '../$types'; +import { getLoginStore } from '$store/login.svelte.ts'; const API_URL = import.meta.env.VITE_API_URL; export const load: PageLoad = async ({ parent, params, fetch }) => { // const { db } = await parent(); const { projectId } = params; + const loginStore = getLoginStore(); /* Login + user details @@ -13,6 +15,7 @@ export const load: PageLoad = async ({ parent, params, fetch }) => { const userResponse = await fetch(`${API_URL}/auth/refresh`, { credentials: 'include' }); if (userResponse.status === 401) { // TODO redirect to different error page to handle login + loginStore.signOut(); throw error(401, { message: `You must log in first` }); } const userObj = await userResponse.json();