Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 1x | import { AppError } from "@ontrack/backend-common";
import { prisma } from "./prisma.js";
/** Бросает 403, если у пользователя нет роли admin. */
export async function assertAdmin(uid: string): Promise<void> {
const me = await prisma.userProfile.findUnique({
where: { firebaseUid: uid },
select: { role: true },
});
if (me?.role !== "admin") {
throw new AppError(403, "FORBIDDEN", "Только для администратора");
}
}
|