From da9d955b5ceca289d5b56d4811e99b461ae66403 Mon Sep 17 00:00:00 2001 From: RA341 Date: Tue, 12 Nov 2024 15:46:31 -0500 Subject: [PATCH] changed admin unauthorized response --- devU-api/src/entities/user/user.middlware.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devU-api/src/entities/user/user.middlware.ts b/devU-api/src/entities/user/user.middlware.ts index 3f323c9..5e046a5 100644 --- a/devU-api/src/entities/user/user.middlware.ts +++ b/devU-api/src/entities/user/user.middlware.ts @@ -6,11 +6,11 @@ import UserService from './user.service' export async function isAdmin(req: Request, res: Response, next: NextFunction) { const userId = req.currentUser?.userId if (!userId) { - return res.status(403).send('Unauthorized') + return res.status(403).json({ 'error': 'Unauthorized' }) } const isAdmin = await UserService.isAdmin(userId) - if (!isAdmin!.isAdmin!) return res.status(403).send('unauthorized') + if (!isAdmin!.isAdmin!) return res.status(403).json({ "error": 'Unauthorized' }) next() }