From 305e3c26458064ba04a26ef9b4e5a83da6beccbf Mon Sep 17 00:00:00 2001 From: philc Date: Mon, 9 Sep 2024 12:50:41 +0200 Subject: [PATCH] add check timehhmm and pagans modifications --- models/Checkjson.js | 1 + models/Pagans.js | 5 ++++- routes/pagans.js | 53 --------------------------------------------- 3 files changed, 5 insertions(+), 54 deletions(-) diff --git a/models/Checkjson.js b/models/Checkjson.js index f516fa9..97ce29b 100755 --- a/models/Checkjson.js +++ b/models/Checkjson.js @@ -87,6 +87,7 @@ Checkjson.schema.properties.format = { "date-time": /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d{1,3}/, stringalphaonly: /^[A-Za-z0-9]{3,}$/, time: /[0-2]\d:[0-5]\d:[0-5]\d\.\d{1,3}/, + timehhmm:/^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/, date: /\d{4}-[01]\d-[0-3]\d/, duration: / /, email: diff --git a/models/Pagans.js b/models/Pagans.js index d19a813..cd18aca 100644 --- a/models/Pagans.js +++ b/models/Pagans.js @@ -49,6 +49,7 @@ Pagans.logout = (alias, tribe, xdays, xhash) => { */ Pagans.keyrecovery = (emailalias, tribe, search, lg) => { + if (log) console.log(currentmod,":try to recover emailalias, tribe, search, lg:",emailalias,tribe,search,lg); if (!["email", "alias"].includes(emailalias)) { return { status: 406, @@ -71,12 +72,14 @@ Pagans.keyrecovery = (emailalias, tribe, search, lg) => { } else { const personpath = `../../${tribe}/objects/persons/itm/${search}.json`; if (fs.existsSync(personpath)) { + const person=fs.readFileSync(personpath) + if (person.recoveryauth) emaillist.push({ alias: search, tribe, lg }); } } emaillist.forEach((e) => { console.log(e); - //const ret = Pagans.sendmailkey(e); + const ret = Pagans.sendmailkey(e); }); if (emaillist.length > 0) { diff --git a/routes/pagans.js b/routes/pagans.js index 9aa5849..8db2f0f 100755 --- a/routes/pagans.js +++ b/routes/pagans.js @@ -417,59 +417,6 @@ router.put("/person/:tribe", checkHeaders, isAuthenticated, (req, res) => { router.post("/keyrecovery", checkHeaders, (req, res) => { const recores=Pagans.keyrecovery(req.body.emailalias,req.body.tribe,req.body.search,req.session.header.xlang) res.status(recores.status).json(recores); - /* - let emailist = []; - let alias = req.body.search; - if (req.body.emailalias == "email") { - req.body.search = req.body.search.toLowerCase(); - const idxreco = `../../${req.body.tribe}/objects/persons/idx/emailrecovery_alias.json`; - if (fs.existsSync(idxreco)) { - const emailreco = fs.readJSONSync(idxreco); - const listalias = emailreco[req.body.search] - ? emailreco[req.body.search] - : []; - listalias.forEach((a) => { - emailist.push({ - alias: a, - tribe: req.body.tribe, - lg: req.session.header.xlang, - }); - }); - } - } else if (req.body.emailalias == "alias") { - const falias = `../../${req.body.tribe}/objects/persons/itm/${req.body.search}.json`; - if (fs.existsSync(falias)) { - emailist.push({ - alias: req.body.search, - tribe: req.body.tribe, - lg: req.session.header.xlang, - }); - } - } else { - res.status(406).json({status:406,ref:"Pagans",msg:"emailaliasnotemailoralias",data:{}}) - } - - emailist.forEach((e) => { - console.log(e); - const ret = Pagans.sendmailkey(e); - }); - - if (emailist.length > 0) { - res.status(200).json({ - status: 200, - ref: "Pagans", - msg: "recoveryemailsent", - data: { numberemailsent: emailist.length }, - }); - } else { - res.status(404).json({ - status: 404, - ref: "Pagans", - msg: "recoveryemailnotfound", - data: { tribe: req.body.tribe }, - }); - } - */ }); module.exports = router;