Brijesh's Git Server — catalyst @ ecc323dd9b78e9b2f3973ef2436f175b6d588241

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
	};
};