From 7c8e38bfb9c03999cc00288a362566dac42e0245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabrice=20PENHO=C3=8BT?= Date: Thu, 10 Sep 2020 11:26:08 +0200 Subject: [PATCH] Correction bug supprimant involontairement le parrain d'un utilisateur. --- controllers/user.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/controllers/user.js b/controllers/user.js index 0e7b832..8c3c156 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -589,12 +589,15 @@ exports.modify = async (req, res, next) => const messageRetour=[txtGeneral.updateOkMessage]; if(req.body.newPassword) req.body.password=await bcrypt.hash(req.body.newPassword, config.bcryptSaltRounds); - if(tool.isEmpty(req.body.newGodfatherId)) - req.body.GodfatherId=null; - else if(req.body.newGodfatherId && req.body.newGodfatherId!==req.params.id && await searchUserById(req.body.newGodfatherId)) - req.body.GodfatherId=req.body.newGodfatherId; - else - messageRetour.push(txt.updatedNeedGoodGodfather); + if(req.body.newGodfatherId!=undefined) + { + const godFather=searchIdGodfather(req.body.newGodfatherId); + if(empty(godFather)) + messageRetour.push(txt.updatedNeedGoodGodfather); + else + req.body.GodfatherId=godFather.id; + } + console.log(req.body); switch(req.connectedUser.User.status) { case "admin":