Skip to content
Discussion options

You must be logged in to vote

For some reason I thought getSupabase was only invokable with a LoadEvent, but it also takes a ServerLoadEvent, so I was able to grab the authenticated client like that:

export const fetchLoggedUser = async (event: ServerLoadEvent): Promise<{ session: Session | null; loggedUser: ILoggedUser | null }> => {
	const { supabaseClient, session } = await getSupabase(event);
	if (!session) {
		return { session: null, loggedUser: null };
	}

	const [profile, roles] = await Promise.all([fetchProfile(session), fetchUserRoles(supabaseClient, session.user.id)]);
	return {
		session,
		loggedUser: {
			id: session.user.id,
			profile,
			roles,
		},
	};
};

I'm a bit concerned about having to do this e…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Etchelon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant