refactor(api/utils): update isAdmin check

make it also check that the user is logged in; eliminates need to type `isLoggedIn()` on the previous line
This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2023-12-06 21:37:54 -05:00
parent e37a54e775
commit c27c81f39c
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

View File

@ -1,6 +1,8 @@
import { H3Event, EventHandlerRequest } from "h3"; import { H3Event, EventHandlerRequest } from "h3";
import { messages } from "../constants"; import { messages } from "../constants";
import isLoggedIn from "./isLoggedIn";
export default function (ev: H3Event<EventHandlerRequest>) { export default function (ev: H3Event<EventHandlerRequest>) {
isLoggedIn(ev);
if (!ev.context.currentUser?.profile.isAdmin) { if (!ev.context.currentUser?.profile.isAdmin) {
throw createError({ throw createError({
statusCode: 403, statusCode: 403,