mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-06 11:30:44 +00:00
16 lines
423 B
TypeScript
16 lines
423 B
TypeScript
import type { LayoutServerLoad } from './$types';
|
|
|
|
import { redirect } from '@sveltejs/kit';
|
|
import { apiWhoami } from '$lib/@api/candidate';
|
|
|
|
export const load: LayoutServerLoad = async ({ cookies, fetch }) => {
|
|
const isAuthenticated = cookies.get('id');
|
|
|
|
if (isAuthenticated) {
|
|
await apiWhoami(fetch).catch((e) => {
|
|
throw redirect(302, '/auth/logout');
|
|
});
|
|
} else {
|
|
throw redirect(302, '/auth/logout');
|
|
}
|
|
};
|