import type { PageServerLoad } from './$types'; import { getUserWithCompany } from '$lib/db/index.server'; import { PERMISSIONS } from '$lib/consts'; import { error } from '@sveltejs/kit'; import { getUserPerms } from '$lib/index.server'; export const load: PageServerLoad = async ({ cookies, params }) => { const id = parseInt(params.user); const perms = getUserPerms(cookies); if (perms >= 0 && (perms & PERMISSIONS.MANAGE_USERS) > 0) { return { user: await getUserWithCompany(id) }; } error(403, 'Unauthorized'); };