diff --git a/routes/pagans.js b/routes/pagans.js index 08e6ade..2b17312 100755 --- a/routes/pagans.js +++ b/routes/pagans.js @@ -346,11 +346,11 @@ router.put("/person/:tribe", checkHeaders, isAuthenticated, (req, res) => { if ( action == "U" && ((req.body.addprofils && - ["seekers", "recruiters", "interviewers"].includes( + ["seekers", "recruiters", "adminrecruiters"].includes( req.body.addprofils )) || (req.body.removeprofils && - ["seekers", "recruiters", "interviewers"].includes( + ["seekers", "recruiters", "adminrecruiters"].includes( req.body.removeprofils ))) ) { @@ -359,8 +359,22 @@ router.put("/person/:tribe", checkHeaders, isAuthenticated, (req, res) => { if (req.body.addprofils) { person.profils.push(req.body.addprofils); } - if (req.body.removeprofils) { - //@todo + if ( + req.body.removeprofils && + person.profils.includes(req.body.removeprofils) + ) { + person.profils = person.profils.filter( + (e) => e !== req.body.removeprofils + ); + Odmdb.cud( + `../../${req.params.tribe}/objects/${req.body.removeprofils}`, + "D", + { alias: req.body.alias }, + { + xprofils: req.session.header.xprofils, + xalias: req.session.header.xalias, + } + ); } } person.dt_update = dayjs().toISOString();