mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 12:30:12 +02:00
21 lines
417 B
TypeScript
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();
|
|
};
|