next/lib/server/middlewareButNotReally/isAdmin.ts

11 lines
288 B
TypeScript

import { H3Event, EventHandlerRequest } from "h3";
import { messages } from "../constants";
export default function (ev: H3Event<EventHandlerRequest>) {
if (!ev.context.currentUser?.profile.isAdmin) {
throw createError({
statusCode: 403,
statusMessage: messages[403],
});
}
}