This commit is contained in:
pfych 2024-10-12 14:08:09 +11:00
commit 0029086b3f
148 changed files with 19047 additions and 0 deletions

View file

@ -0,0 +1,19 @@
import { NextFunction, Response } from 'express';
import { isAdminSub } from '../baseblocks/admin/admin.service';
import { RequestContext } from '../util/request-context.type';
export const isAdmin = async (
req: RequestContext,
res: Response,
next: NextFunction,
) => {
const userSub = req.currentUserSub;
const isAdmin = await isAdminSub(userSub);
if (!isAdmin) {
res.status(403).json({
error: 'User does not have permission',
});
return;
}
next();
};