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":