From e09bcb420b61994fa1035694ecc7a2eebc2e0a1f Mon Sep 17 00:00:00 2001 From: Saransh Balyan Date: Fri, 2 Aug 2024 22:20:35 +0530 Subject: [PATCH] refractor --- User/Routes/user.protected.routes.js | 2 +- Utils/Middlewares/permissions.middleware.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/User/Routes/user.protected.routes.js b/User/Routes/user.protected.routes.js index b0897f9..f55d706 100644 --- a/User/Routes/user.protected.routes.js +++ b/User/Routes/user.protected.routes.js @@ -13,7 +13,7 @@ Router.get('/', getAllUsers); Router.get('/logout', logout); /* - * Router.delete('/customer', validateCustomerAdmin(), deleteCustomerUser); + * Router.delete('/customer', validateIssuer(), deleteCustomerUser); * Router.get('/team', validatePermission('Team', 'view'), getTeam); * Router.get('/', getUserDetailsByEmail); * Router.post('/', validate(emailBodyValidation), getUserDetailsByEmail); diff --git a/Utils/Middlewares/permissions.middleware.js b/Utils/Middlewares/permissions.middleware.js index 1ac0b7b..e749769 100644 --- a/Utils/Middlewares/permissions.middleware.js +++ b/Utils/Middlewares/permissions.middleware.js @@ -24,9 +24,9 @@ const validateSuperAdmin = () => (req, res, next) => { return getError(e, res); } }; -const validateCustomerAdmin = () => (req, res, next) => { +const validateIssuer = () => (req, res, next) => { try { - if (!req.user.customerAdmin) return res.status(401).json({ error: errorContstants.UNAUTHORIZED }); + if (!req.user.type=='issuer') return res.status(401).json({ error: errorContstants.UNAUTHORIZED }); return next(); } catch (e) { return getError(e, res); @@ -50,4 +50,4 @@ const validateUserProject = () => async (req, res, next) => { } }; -export { validateCustomerAdmin, validatePermission, validateSuperAdmin, validateUserProject }; +export { validateIssuer, validatePermission, validateSuperAdmin, validateUserProject };