2023-10-03 00:33:54 -04:00
|
|
|
import { H3Event, EventHandlerRequest } from "h3";
|
|
|
|
import { messages } from "../constants";
|
2023-12-06 21:37:54 -05:00
|
|
|
import isLoggedIn from "./isLoggedIn";
|
2023-10-03 00:33:54 -04:00
|
|
|
export default function (ev: H3Event<EventHandlerRequest>) {
|
2023-12-06 21:37:54 -05:00
|
|
|
isLoggedIn(ev);
|
2023-10-03 00:33:54 -04:00
|
|
|
if (!ev.context.currentUser?.profile.isAdmin) {
|
|
|
|
throw createError({
|
|
|
|
statusCode: 403,
|
|
|
|
statusMessage: messages[403],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|