Skip to content

Commit

Permalink
fix(+page): remove user details from localStorage in case of session …
Browse files Browse the repository at this point in the history
…expiration (#1965)
  • Loading branch information
NSUWAL123 authored Dec 9, 2024
1 parent 740504c commit aacabbc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mapper/src/routes/[projectId]/+page.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
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
*/
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();
Expand Down

0 comments on commit aacabbc

Please sign in to comment.