From 484231144d090ad08cddf3b4e5103c7ebc26b6e6 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 6 Sep 2024 10:56:07 -0700 Subject: [PATCH] Add superadmin check --- Server/controllers/authController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Server/controllers/authController.js b/Server/controllers/authController.js index 69483f5e9..fe406a6b6 100644 --- a/Server/controllers/authController.js +++ b/Server/controllers/authController.js @@ -463,12 +463,12 @@ const deleteUserController = async (req, res, next) => { throw new Error(errorMessages.DB_USER_NOT_FOUND); } - // 1. Find all the monitors associated with the user id + // 1. Find all the monitors associated with the team ID if superadmin const result = await req.db.getMonitorsByTeamId({ params: { teamId: user.teamId }, }); - if (result?.monitors.length > 0) { + if (user.role.includes("superadmin") && result?.monitors.length > 0) { //2. Remove all jobs, delete checks and alerts await Promise.all( monitors.map(async (monitor) => {