mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-13 11:03:49 +00:00
19 lines
421 B
TypeScript
19 lines
421 B
TypeScript
import { redirect } from '@sveltejs/kit';
|
|
import type { PageServerLoad } from './$types';
|
|
|
|
export const load: PageServerLoad = async ({ locals: { supabase, safeGetSession } }) => {
|
|
const { session } = await safeGetSession();
|
|
|
|
if (!session) {
|
|
redirect(303, '/');
|
|
}
|
|
|
|
const { data: user } = await supabase
|
|
.from('users')
|
|
.select(`name, id`)
|
|
.eq('id', session.user.id)
|
|
.single();
|
|
|
|
return { session, user };
|
|
};
|