FBLA25/src/routes/admin/postings/+page.server.ts
drake 8932165f7b
All checks were successful
ci / docker_image (push) Successful in 2m35s
ci / deploy (push) Successful in 31s
changes
2025-03-20 21:30:54 -05:00

17 lines
557 B
TypeScript

import type { PageServerLoad } from './$types';
import { getPostings, getUsers } 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, url }) => {
const search = url.searchParams.get('searchPostings');
const perms = getUserPerms(cookies);
if (perms >= 0 && (perms & PERMISSIONS.MANAGE_POSTINGS) > 0) {
return {
postings: await getPostings(search)
};
}
error(403, 'Unauthorized');
};