Brijesh's Git Server — catalyst @ master

client/src/routes/+page.server.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';

export const load: PageServerLoad = async (event) => {
	const session = await event.locals.auth();

	if (!session?.user?.name) {
		if (event.url.pathname !== '/login') {
			throw redirect(303, `/login`);
		}
	}

	return {
		session
	};
};