16 lines
367 B
TypeScript
16 lines
367 B
TypeScript
import type { LayoutServerLoad } from './$types';
|
|
import { prisma } from '$lib/db';
|
|
|
|
export const load: LayoutServerLoad = async ({ locals }) => {
|
|
if (!locals.user?.id) {
|
|
return { userRoleId: null };
|
|
}
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: { id: locals.user.id },
|
|
select: { roleId: true }
|
|
});
|
|
|
|
return { userRoleId: user?.roleId ?? null };
|
|
};
|