FBLA25/src/routes/admin/users/[user]/+page.server.ts
drake be83b7570d
All checks were successful
ci / docker_image (push) Successful in 1m32s
ci / deploy (push) Successful in 16s
dev
2025-01-26 19:12:15 -06:00

17 lines
532 B
TypeScript

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');
};