Add API utility for requiring an admin session
This commit is contained in:
parent
b0d5cdf791
commit
b2f48e98e0
3 changed files with 13 additions and 15 deletions
|
@ -70,3 +70,14 @@ export async function requireServerSession(event: H3Event) {
|
|||
});
|
||||
return session;
|
||||
}
|
||||
|
||||
export async function requireServerSessionWithAdmin(event: H3Event) {
|
||||
const session = await requireServerSession(event);
|
||||
if (session.account.type !== "admin") {
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Forbidden",
|
||||
});
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue