better sighnout and more user info
This commit is contained in:
22
src/routes/private/home/+page.server.ts
Normal file
22
src/routes/private/home/+page.server.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
// src/routes/my-page/+page.server.ts
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async ({ locals }) => {
|
||||
// get the logged-in user
|
||||
const { data: { user }, error: authError } = await locals.supabase.auth.getUser();
|
||||
|
||||
const { data: user_profile, error: profileError } = await locals.supabase.from('profiles').select('*, section:sections (id, name)').eq('id', user?.id).single();
|
||||
|
||||
if (authError) {
|
||||
console.error('Supabase auth error:', authError);
|
||||
throw new Error('Could not get user');
|
||||
}
|
||||
|
||||
if (profileError) {
|
||||
console.error('Supabase profile error:', profileError);
|
||||
throw new Error('Could not get user profile');
|
||||
}
|
||||
|
||||
return { user, user_profile };
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user