feat(api/utils): add isadmin check
This commit is contained in:
parent
a2300d959c
commit
1338e87238
10
lib/server/middlewareButNotReally/isAdmin.ts
Normal file
10
lib/server/middlewareButNotReally/isAdmin.ts
Normal file
@ -0,0 +1,10 @@
|
||||
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],
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user