Correction bug supprimant involontairement le parrain d'un utilisateur.

This commit is contained in:
Fabrice PENHOËT 2020-09-10 11:26:08 +02:00
parent 5c8d68733f
commit 7c8e38bfb9
1 changed files with 9 additions and 6 deletions

View File

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