Files
feishin/server/middleware/authenticate-admin.ts
T
2022-10-25 16:52:45 -07:00

21 lines
417 B
TypeScript

import { NextFunction, Request, Response } from 'express';
export const authenticateAdmin = (
req: Request,
res: Response,
next: NextFunction
) => {
if (!req.authUser.isAdmin) {
return res.status(403).json({
error: {
message: 'This action requires an administrator account.',
path: req.path,
},
response: 'Error',
statusCode: 403,
});
}
return next();
};