mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-06 11:30:44 +00:00
19 lines
472 B
TypeScript
19 lines
472 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) {
|
|
const whoami = await apiWhoami(fetch).catch((e) => {
|
|
throw redirect(302, '/auth/logout');
|
|
});
|
|
return {
|
|
whoami: whoami
|
|
};
|
|
} else {
|
|
throw redirect(302, '/auth/logout');
|
|
}
|
|
};
|