From 01cb59a4663b11d3360a6d778ec3d08081f696ab Mon Sep 17 00:00:00 2001 From: Ronald-pro <36841157+Ronald-pro@users.noreply.github.com> Date: Mon, 30 Sep 2024 13:07:16 +0300 Subject: [PATCH] checks on menstrual delete --- routes/processes/nishauri_new.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/routes/processes/nishauri_new.js b/routes/processes/nishauri_new.js index 504cd26..15e6f19 100644 --- a/routes/processes/nishauri_new.js +++ b/routes/processes/nishauri_new.js @@ -5468,12 +5468,16 @@ router.delete( let id = req.params.id; // Get the menstrual cycle ID from URL parameters let user_id = req.body.user_id; + + let decoded_user_id = base64.decode(user_id); + + let today = moment(new Date()) .tz("Africa/Nairobi") .format("YYYY-MM-DD HH:mm:ss"); // Verify user exists - let user = await NUsers.findOne({ where: { id: base64.decode(user_id) } }); + let user = await NUsers.findOne({ where: { id: decoded_user_id } }); if (!user) { return res.status(404).json({ @@ -5484,7 +5488,7 @@ router.delete( let menstrual_cycle = await NMenstrual.findOne({ where: { - [Op.and]: [{ id: id }, { user_id: base64.decode(user_id) }] + [Op.and]: [{ id: id }, { user_id: decoded_user_id }] } });