18 lines
435 B
TypeScript
18 lines
435 B
TypeScript
import type { LayoutServerLoad } from './$types'
|
|
|
|
export const load: LayoutServerLoad = async ({ locals: { safeGetSession, getUserProfile }, cookies }) => {
|
|
const { session, user } = await safeGetSession()
|
|
|
|
// Get the user profile if the user is authenticated
|
|
let profile = null
|
|
if (user) {
|
|
profile = await getUserProfile(user.id)
|
|
}
|
|
|
|
return {
|
|
session,
|
|
user,
|
|
profile,
|
|
cookies: cookies.getAll(),
|
|
}
|
|
} |