From aacabbcfe918e1128837ed3e54b18b798c6baf95 Mon Sep 17 00:00:00 2001 From: Nishit Suwal <81785002+NSUWAL123@users.noreply.github.com> Date: Mon, 9 Dec 2024 18:26:14 +0545 Subject: [PATCH] fix(+page): remove user details from localStorage in case of session expiration (#1965) --- 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();