Skip to content

Commit

Permalink
checks on menstrual delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald-pro committed Sep 30, 2024
1 parent 9fe3bf3 commit 01cb59a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions routes/processes/nishauri_new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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 }]
}
});

Expand Down

0 comments on commit 01cb59a

Please sign in to comment.