diff --git a/models/ASUPlg/Checkjson_en.json b/models/ASUPlg/Checkjson_en.json deleted file mode 100644 index b55d69f..0000000 --- a/models/ASUPlg/Checkjson_en.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "validcheck":"Your data are valid", - "typedoesnnotexistinschema":"This type in your propertie is not manage by Checkjson.js", - "dataerrpropertie":"Check your data that not fit your schema rules propertie", - "dataerrpropertiesrequired":"This propertie is required and not present in your data" -} \ No newline at end of file diff --git a/models/ASUPlg/Checkjson_fr.json b/models/ASUPlg/Checkjson_fr.json deleted file mode 100644 index a76cb1c..0000000 --- a/models/ASUPlg/Checkjson_fr.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "validcheck":"Your data are valid", - "typedoesnnotexistinschema":"This type in your propertie is not manage by Checkjson.js", - "dataerrpropertie":"Check your data that not fit your schema rules propertie", - "dataerrpropertiesrequired":"This propertie is required and not present in your data", - "externalrefnotload":"You have in your schema a relative sub schema, you have to load it before" -} \ No newline at end of file diff --git a/models/ASUPlg/Nations_fr.json b/models/ASUPlg/Nations_fr.json deleted file mode 100644 index 8b2739b..0000000 --- a/models/ASUPlg/Nations_fr.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "nationnamedesc":"Nom unique d'une nation dans un monde social", - "nationnamedesclong":"Nom unique identifiant une nation dans le monde social créer par un maire d'une nouvelle ville avec un contrat sociale specifique", - "nationnameinfo":"

Une nation posséde un nom unique, un contrat sociale (contracts/name.js) signé et validé par tous les maires des villes associées à cette nation

", - "statusdesc":"Statut de la nation", - "statusactive":"Nation active" -} \ No newline at end of file diff --git a/models/ASUPlg/Notifications_fr.json b/models/ASUPlg/Notifications_fr.json deleted file mode 100644 index 558789c..0000000 --- a/models/ASUPlg/Notifications_fr.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "missingconf":"Il manque un smtp/sms valide pour {{tribe}} ou sur le serveur /conf.json", - "missingdata":"Il manque des données obligatoire dans data {{#missingk}} {{.}} {{/missingk}}", - "missingfile":"Le ou les fichiers suivants n'existent pas {{#missingfile}} {{.}} {{/missingfile}}", - "errsendmail":"Une erreur s'est produite lors de l'envoie de l'email", - "successfullsentemail":"Email correctement envoyé", - "errsendsms":"Une erreur s'est produite lors de l'envoie du sms", - "successfullsentsms":"Sms bien envoyé à {{To}}", - "registersuccess":"Vous avez bien été enregistré pour être recontacté.", - "formaterror":"Verifier vos données", - "typekeyunknown":"Verifier typekey qui doit etre email ou telephone et qui est {{typeky}}", - "destinnotallow":"Check {{destin}} that not exist" -} \ No newline at end of file diff --git a/models/ASUPlg/Odmdb_en.json b/models/ASUPlg/Odmdb_en.json deleted file mode 100644 index aa64411..0000000 --- a/models/ASUPlg/Odmdb_en.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "alreadyexist": "An {{objectname}} object with the {{key}} key already exists with {{val}}", - "doesnotexist": "The {{objectname}} object does not exist with {{key}}:{{val}}", - "getschema": "Schema {{{conf.name}}}", - "schemanotfound": "Schema not found in {{{schemaPath}}}", - "pathnamedoesnotexist": "The directory does not exist {{{indexpath}}}", - "objectfiledoesnotexist": "The file does not exist {{{objectpath}}}", - "cudsuccessfull": "Update successful", - "successfulcreatewithoutemail":"Create without sending an email", - "successfulcreatewitemail":"Create you will receive an email", - "missingprimarykey": "Missing a primary key apxid to store and identify objects", - "unconsistencyapxidx": "The index {{name}} must contain at least {{apxid}} in objkey because keyval is not unique", - "profilnotallow": "As {{person}} your profiles are not allow, this action is not authorized", - "profilallow": "You are allowed for this action", - "successreindex": "Object reindexed from items, your indexes are up to date", - "indexexist":"The index exists", - "typenotavailable":"The type: {{type}} for the propertie: {{propertie}} of the object:{{objectPathname}} is not taken into account for indexing", - "objectslist":"List of objects from apxtri and {{tribe}}", - "errordelete":"Sorry, unable to delete this account" - } \ No newline at end of file diff --git a/models/ASUPlg/Odmdb_fr.json b/models/ASUPlg/Odmdb_fr.json deleted file mode 100644 index 9cff8ce..0000000 --- a/models/ASUPlg/Odmdb_fr.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "alreadyexist": "Un object {{objectname}} avec la clé {{key}} existe déjà avec {{val}}", - "doesnotexist": "L'object {{objectname}} n'existe pas avec {{key}}:{{val}}", - "getschema": "Schema {{{conf.name}}}", - "schemanotfound": "Schema introuvable dans {{{schemaPath}}}", - "pathnamedoesnotexist": "Le repertoire n'existe pas {{{indexpath}}}", - "objectfiledoesnotexist": "Le fichier n'existe pas {{{objectpath}}}", - "cudsuccessfull": "Mise à jour effectuée avec succés", - "successfulcreatewithoutemail":"Créer sans envoi d'email", - "successfulcreatewitemail":"Créer vous allez recevoir un email", - "missingprimarykey": "Il manque une clé primaire apxid pour stocker et identifier les objects", - "unconsistencyapxidx": "L'index {{name}} doit contenir en objkey au moins {{apxid}} car keyval n'est pas unique", - "profilnotallow": "Vous n'avez pas le profil pour faire cette action.", - "profilallow": "Vous avez été authorisé à faire cette action", - "successreindex": "Objet reindexé à partir des items, vos index sont à jour", - "indexexist":"L'indexe existe", - "typenotavailable":"Le type: {{type}} pour la propertie : {{propertie}} de l'object :{{objectPathname}} n'est pas pris en compte pour l'indexation", - "objectslist":"Liste des objects d'apxtri et de {{tribe}}", - "errordelete":"Desolé impossible de supprimer ce compte" -} diff --git a/models/ASUPlg/Pagans_en.json b/models/ASUPlg/Pagans_en.json deleted file mode 100644 index 271234f..0000000 --- a/models/ASUPlg/Pagans_en.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "aliasexist":"This alias {{alias]} exist", - "aliasdoesnotexist":"This alias {{alias}} does not exist ", - "personexist":"This person {{alias}} exist for {{tribeid}}", - "successfullcreate": "This identity {{alias}} creation was successfull. {{#withemail}} An email was sent to {{email}}, if you do not receive it, please download your keys before living this page.{{/withemail}}", - "successfulluppdate": "Your alias as a Person is now update into {{tribeid}}", - "tribedoesnotexist": "Your tribe {{tribeid}} does not exist in this town" -} diff --git a/models/ASUPlg/Pagans_fr.json b/models/ASUPlg/Pagans_fr.json deleted file mode 100644 index 3ec4113..0000000 --- a/models/ASUPlg/Pagans_fr.json +++ /dev/null @@ -1,15 +0,0 @@ -{ "invalidalias":"Alias doit être composé exclusivement de minuscules ou de chiffres et contenir au moins 4 caracteres", - "aliasexist": "Cet alias {{alias}} existe", - "emailerr": "Verifier votre email {{email}}", - "aliasorprivkeytooshort": "Vérifiez votre alias et votre clé privée", - "aliasdoesnotexist": "Cet alias {{alias}} n'existe pas", - "personexist": "Cette personne {{alias}} existe pour {{tribeid}}", - "persondoesnotexist": "Cette personne {{alias}} n'existe pas pour {{tribeid}}", - "successfulcreate":"Votre identité {{alias}} a été créee à partir de vos clés.{{#emailsent}} Un email a été envoyé à {{email}}, si vous ne le recevez pas, veuillez télécharger vos clés avant de quitter cette page.{{/emailsent}} {{#emailerror}}Un problème lors de l'envoi sur {{email}} s'est produit. Veuillez télécharger vos clés avant de quitter cette page.{{/emailerror}}
{{#createperson}}Félicitation Votre compte est ouvert chez {{tribe}}. {{/createperson}} {{#errorperson}}Attention votre identité n'a pas été associée à {{tribe}}. Vous pourrez rejoindre {{tribe}} dans l'écran suivant. {{/errorperson}}", - "successfulluppdate": "Votre alias en tant que Personne est maintenant mis à jour dans {{tribeid}}", - "errcreate": "Desolé, un probléme inconnu empeche la creation", - "logout": "Votre token a été supprimé du server", - "emailnotfound":"Auncune identité n'a été enregistrée sur {{tribe}} avec l'email {{email}} ", - "recoveryemailsent":"Votre email: {{email}} dispose de {{nbalias}} identitées sur {{tribe}}, nous avons envoyés {{nbsent}} messages sans problèmes.", - "templatedoesnotexist":"Le template {{tplfile}} n'existe pas" -} diff --git a/models/ASUPlg/Tribes_fr.json b/models/ASUPlg/Tribes_fr.json deleted file mode 100644 index 9b8f806..0000000 --- a/models/ASUPlg/Tribes_fr.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "actionmissing":"L'action {{data.action}} n'existe pas pour la tribut {{data.tribe}}." -} \ No newline at end of file diff --git a/models/ASUPlg/middlewares_en.json b/models/ASUPlg/middlewares_en.json deleted file mode 100644 index 2e640f9..0000000 --- a/models/ASUPlg/middlewares_en.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "errrequest": "Backend seems not available", - "unconsistentpgp": "Your keys are not consistent {{err}}", - "missingheader": "Some header miss to have a valid request: {{#missinghearder}} {{.}} {{/missingheader}}", - "tribeiddoesnotexist": "Header xtribe: {{xtribe}} does not exist in this town you cannot access", - "unconsistentcleartextmessage":"Your xhash: {{xhash}} is not consistent as a clear msg {{{clearmsg}}}", - "authenticated": "Your alias: {{{xalias}}} is authenticated", - "notauthenticated": "Your alias: {{xalias}} is not authenticated {{^xaliasexists}} and this alias does not exist !{{/xaliasexists}}", - "signaturefailled": "Your signature is not valid for your alias." -} diff --git a/models/ASUPlg/middlewares_fr.json b/models/ASUPlg/middlewares_fr.json deleted file mode 100644 index a81ba12..0000000 --- a/models/ASUPlg/middlewares_fr.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "errrequest": "Le serveur ne semble pas répondre", - "unconsistentpgp": "Vos clés ne sont pas conforme {{err}}", - "missingheader": "Certains en-têtes manquent pour avoir une requête valide : {{#missinghearder}} {{.}} {{/missingheader}}", - "tribeiddoesnotexist": "L'en-tête xtribe : {{xtribe}} n'existe pas dans cette ville, vous ne pouvez pas y accéder", - "unconsistentcleartextmessage":"Votre xhash: {{xhash}} n'est pas lisible par openpgp.js avec le clearmsg: {{{clearmsg}}}", - "authenticated": "Votre alias {{{xalias}}} est authentifié", - "notauthenticated": "Votre alias : {{xalias}} n'est pas authentifié {{^xaliasexists}} et cet alias n'existe pas !{{/xaliasexists}}", - "signaturefailled": "Desolé votre signature n'est pas valide pour cet alias." -} diff --git a/models/Odmdb.js b/models/Odmdb.js index 519b690..506e27b 100644 --- a/models/Odmdb.js +++ b/models/Odmdb.js @@ -160,14 +160,14 @@ Odmdb.Schema = (objectPathname, validschema, lg = "en") => { const replacelg = (data) => { // data.en version schema de base, data.fr version schema traduite Object.keys(data.lg).forEach((k) => { - console.log(k); + //console.log(k); if (data.lg[k].title) data.en[k].title = data.lg[k].title; if (data.lg[k].description) data.en[k].description = data.lg[k].description; if (data.lg.properties) { - console.log("properties"); - console.log(data.en.properties); - console.log(data.lg.properties); + //console.log("properties"); + //console.log(data.en.properties); + //console.log(data.lg.properties); const res = replacelg({ en: data.en.properties, lg: data.lg.properties, @@ -184,12 +184,13 @@ Odmdb.Schema = (objectPathname, validschema, lg = "en") => { // lance requete http pour recuperer le schema avec un await axios } else { schemaPath = `../../${schemaPath}`; - if (log) + /*if (log) console.log( currentmod, "resolve path schemaPath:", path.resolve(schemaPath) ); + */ if (!fs.existsSync(schemaPath)) { return {}; } else { @@ -234,7 +235,7 @@ Odmdb.Schema = (objectPathname, validschema, lg = "en") => { (optionstype = "idx"); optionsfile = path.resolve(`../../${propertie.options["$ref"]}.json`); } - if (log) console.log(currentmod, "Lien vers options:", optionsfile); + //if (log) console.log(currentmod, "Lien vers options:", optionsfile); if (!fs.existsSync(optionsfile)) { propertie.msg = "missingref"; return propertie; @@ -250,7 +251,7 @@ Odmdb.Schema = (objectPathname, validschema, lg = "en") => { return propertie; }; - if (log) console.log(currentmod, `${objectPathname}/conf.json`); + //if (log) console.log(currentmod, `${objectPathname}/conf.json`); const res = { status: 200, ref: "Odmdb", @@ -437,7 +438,7 @@ Odmdb.search = (objectPathname, objsearch, role) => { role.xprofils = role.xprofils.filter((e) => e !== "owner"); } objsearch.fields.forEach((f) => { - if (accessright.R && accessright.R.length == 0 || accessright.R.includes(f)) { + if (accessright.R && (accessright.R.length == 0 || accessright.R.includes(f))) { ifields[f] = itm[f]; } else { //ifields[f] = "unauthorized"; @@ -499,72 +500,6 @@ Odmdb.r = (objectPathname, apxid, role) => { return { status: 200, ref: "Odmdb", msg: "profilallow", data }; }; -/** - * To get an array of item (itm) per primarykey with a list of field - * Object are store in objectPath/objectName/conf.json contain - * - * @objectPathname where object are store (where /object/conf.json indicate where the schema is) - * @uuidprimarykeyList list of uuid requested - * @role {xalias,xprofiles} allow to get accessright come from header - * @propertiesfilter (optionnal) key to return for each object (if undefined then return all) - * @Return {status:200; data:{uuid:{data filter by @propertiesfilter},uuid:"notfound"}} - -ASUP doit être gerer au niveau des view des index - - -*/ -Odmdb.ASUPreads = (objectPathname, apxidlist, role, propertiesfilter) => { - const res = { status: 200, data: {} }; - const getschema = Odmdb.Schema(objectPathname, true); - if (getschema.status != 200) return getschema; - // Test if readable at least if owner - role.xprofils.push("owner"); - const accessright = (Odmdb.accessright = - (getschema.data.schema.apxaccessright, role.xprofils)); - if (!accessright.R) { - return { - status: 403, - ref: "Odmdb", - msg: "profilnotallow", - data: { crud: "R", accessright }, - }; - } - apxidlist.forEach((id) => { - if (fs.existsSync(`${objectPathname}/itm/${id}.json`)) { - const objectdata = fs.readJsonSync(`${objectPathname}/itm/${id}.json`); - if (objectdata.owner && objectdata.owner == role.xalias) { - if (!role.xprofils.includes("owner")) role.xprofils.push("owner"); - } else { - if (role.xprofils.includes("owner")) - role.xprofils = role.xprofils.filter((e) => e !== "owner"); - } - const accessright = Odmdb.accessright( - getschema.data.schema.apxaccessright, - role - ); - if (!accessright.R) { - res.data[id] = "forbiden"; - } else { - let newpropertiesfilter = Object.keys(objectdata); - if (accessright.R.length > 0) { - const setaccess = new Set(accessright.R); - if (!propertiesfilter) propertiesfilter = Object.keys(objectdata); - newpropertiesfilter = propertiesfilter.filter((f) => - setaccess.has(f) - ); - } - const objinfo = {}; - newpropertiesfilter.forEach((k) => { - if (objectdata[k]) objinfo[k] = objectdata[k]; - }); - res.data[id] = objinfo; - } - } else { - res.data[id] = "notfound"; - } - }); - return res; -}; /** * Convert profils in accessright * @param {*} apxaccessright from schema object {profilname:{R}} @@ -771,7 +706,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => { currentmod, `${objectPathname}/itm/${chkdata.data.apxid}.json` ); - if (log) console.log(currentmod, chkdata.data.itm); + //if (log) console.log(currentmod, chkdata.data.itm); fs.outputJSONSync( `${objectPathname}/itm/${chkdata.data.apxid}.json`, chkdata.data.itm @@ -802,7 +737,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => { * */ Odmdb.runidx = (objectPathname, schema) => { - if (log) console.log(currentmod, `idx for ${objectPathname}`); + //if (log) console.log(currentmod, `idx for ${objectPathname}`); if (!schema || !schema.apxid) { const getschema = Odmdb.Schema(objectPathname, true); if (getschema.status != 200) return getschema; @@ -831,7 +766,7 @@ Odmdb.runidx = (objectPathname, schema) => { const itm = fs.readJSONSync(i); Object.keys(ventil).forEach((n) => { let keep = true; - console.log(`Index name: ${n}`) + //console.log(`Index name: ${n}`) if (ventil[n].filter != "") { try { keep = eval(ventil[n].filter); @@ -872,7 +807,7 @@ Odmdb.runidx = (objectPathname, schema) => { ventil[n].keyvaltype == "string" ? [itm[ventil[n].keyval]] : itm[ventil[n].keyval]; - console.log(ventil[n].keyval, itm[ventil[n].keyval], itm) + //console.log(ventil[n].keyval, itm[ventil[n].keyval], itm) // itm[ventil[n].keyval] is an array listval.forEach((val) => { if (!ventil[n].data[val]) ventil[n].data[val] = []; @@ -886,8 +821,8 @@ Odmdb.runidx = (objectPathname, schema) => { itm[ventil[n].keyval.split(".")[0]] ) { let itmval = JSON.parse(JSON.stringify(itm)); - if (log) console.log(currentmod, ventil[n].keyval); - if (log) console.log(currentmod, itmval); + //if (log) console.log(currentmod, ventil[n].keyval); + //if (log) console.log(currentmod, itmval); ventil[n].keyval .split(".") .forEach((i) => (itmval = itmval[i] ? itmval[i] : null)); @@ -1053,7 +988,7 @@ Odmdb.ASUPidxfromitm = ( } return { status: 200, ref: "Odmdb", msg: "successreindex", data: {} }; }; -Odmdb.updatefromidxall = (objectname, idxname, data, lastupdate) => { +Odmdb.ASUPupdatefromidxall = (objectname, idxname, data, lastupdate) => { /** * Update all itm of objectname from index idx/idxname with data * if itm exist in local and not in data then /ojectname/conf.json.lastupdate = now diff --git a/models/Pagans.js b/models/Pagans.js index 74d3cd0..d19a813 100644 --- a/models/Pagans.js +++ b/models/Pagans.js @@ -19,7 +19,6 @@ const log = conf.api.activelog.includes(currentmod); */ const Pagans = {}; - /** * Remove authentification token after a logout * @param {string} alias @@ -41,6 +40,61 @@ Pagans.logout = (alias, tribe, xdays, xhash) => { return { status: 200, ref: "Pagans", msg: "logout" }; }; +/** + * Recovery keys by email or by alias and send one mail per alias + * @Param emailalias (2 options email or alias) + * @Param tribe and existing tribe on this serveur + * @Param search a text string to looking for (as email or as alias) + * @Param lg language to send email + */ + +Pagans.keyrecovery = (emailalias, tribe, search, lg) => { + if (!["email", "alias"].includes(emailalias)) { + return { + status: 406, + ref: "Pagans", + msg: "emailaliasnotemailoralias", + data: {}, + }; + } + let emaillist = []; + if (emailalias == "email") { + search = search.toLowerCase(); + const idxreco = `../../${tribe}/objects/persons/idx/emailrecovery_alias.json`; + if (fs.existsSync(idxreco)) { + const emailreco = fs.readJSONSync(idxreco); + const listalias = emailreco[search] ? emailreco[search] : []; + listalias.forEach((a) => { + emaillist.push({ alias: a, tribe, lg }); + }); + } + } else { + const personpath = `../../${tribe}/objects/persons/itm/${search}.json`; + if (fs.existsSync(personpath)) { + emaillist.push({ alias: search, tribe, lg }); + } + } + emaillist.forEach((e) => { + console.log(e); + //const ret = Pagans.sendmailkey(e); + }); + + if (emaillist.length > 0) { + return { + status: 200, + ref: "Pagans", + msg: "recoveryemailsent", + data: { numberemailsent: emaillist.length }, + }; + } + return { + status: 404, + ref: "Pagans", + msg: "recoveryemailnotfound", + data: { tribe }, + }; +}; + /** * @param {string} alias a alias that exist or not * @return {object} { status: 200, ref:"pagans",msg:"aliasexist",data: { alias, publicKey } } diff --git a/routes/odmdb.js b/routes/odmdb.js index 68da169..e815515 100644 --- a/routes/odmdb.js +++ b/routes/odmdb.js @@ -102,7 +102,7 @@ router.get( ); /** - * @api {get} /api/adminapi/odmdb/idx/:tribe/:objectname/:indexname - index Get + * @api {get} adminapi/odmdb/idx/:tribe/:objectname/:indexname - index Get * @apiGroup Odmdb * @apiName getIndexbyindexname * @apiDescription Get index file for an object @@ -421,12 +421,13 @@ router.get( xalias: req.session.header.xalias, } ); - res.status(200).json({ + res.status(readobj.status).json(readobj); + /*res.status(200).json({ status: 200, ref: "Odmdb", msg: "itmfound", data: fs.readJsonSync(objectpath), - }); + });*/ } else { res.status(404).json({ status: 404, @@ -438,11 +439,11 @@ router.get( } ); /** - * @api {get} https://wall-ants.ndda.fr/adminapi/Checkjson.js - schema Checkjson.js + * @api {get} https://anypaxtridns/adminapi/Checkjson.js - schema Checkjson.js * @apiGroup Odmdb * @apiName checkjsonjs * @apiDescription Public js lib to import in a browser by :
- * `````` + * `````` * to import in a node.js:
* ```const Checkjson = require(`Checkjson.js`);``` * @@ -456,8 +457,12 @@ router.get( * - {status:417, multimsg:[{ref:"Checkjson",msg:"errorkey",data:{}}]}
* * To identify issues, get the language errorkey list with a get - * MUST BE UPDATE with conf access https://wall-ants.ndda.fr/adminapi/objects/tplstring/Checkjson_lg.json - * + * + * To check a property from an existing format + * + * Checkjson.testformat=(str, format)=>{ + * return null if format does not exist in Checkjson.schema.properties.format + * return true if str respect the format (false in other case) */ /** diff --git a/routes/pagans.js b/routes/pagans.js index a9e3e95..9aa5849 100755 --- a/routes/pagans.js +++ b/routes/pagans.js @@ -14,14 +14,10 @@ const currentmod = "pagans"; const log = conf.api.activelog.includes(currentmod); const router = express.Router(); -/** - * /api/models/Pagans.js - * - * Managed: /** * Alias exist then return public key or not - * @api {get} /api/adminapi/pagans/alias/:alias - alias Get + * @api {get} adminapi/pagans/alias/:alias - alias Get * @apiName isalias * @apiGroup Pagans * @apiDescription If alias exist return its publickey @@ -44,7 +40,7 @@ router.get("/alias/:alias", (req, res) => { res.status(getalias.status).send(getalias); }); /** - * @api {get} /api/adminapi/pagans/logout - pagan Logout + * @api {get} adminapi/pagans/logout - pagan Logout * @apiName Removetoken * @apiGroup Pagans * @apiDescription Remove server's token only the owner of the token (no one else can delete a token ) @@ -66,7 +62,7 @@ router.get("/logout", checkHeaders, isAuthenticated, (req, res) => { res.status(logout.status).json(logout); }); /** - * @api {get} /api/adminapi/pagans/isauth - pagan isAuthenticated? + * @api {get} adminapi/pagans/isauth - pagan isAuthenticated? * @apiName isAuth * @apiGroup Pagans * @apiDescription Check if pagan's token is still valid @@ -92,10 +88,9 @@ router.get("/isauth", checkHeaders, isAuthenticated, (req, res) => { }, }); }); -// @a pi Body {object} schema:pagans /nationchains/schema/pagans.json /** - * @api {post} /api/adminapi/pagans - pagan Post + * @api {post} adminapi/pagans - pagan Post * @apiName addpagan * @apiGroup Pagans * @apiDescription @@ -217,7 +212,7 @@ router.post("/", checkHeaders, isAuthenticated, async (req, res) => { } }); /** - * @api {delete} /api/adminapi/pagans/alias/:alias - pagan Delete + * @api {delete} adminapi/pagans/alias/:alias - pagan Delete * @apiName deletepagan * @apiGroup Pagans * @apiDescription @@ -253,7 +248,7 @@ router.delete("/alias/:alias", checkHeaders, isAuthenticated, (req, res) => { res.status(result.status).send(result); }); /** - * @api {delete} /api/adminapi/pagans/person/:tribe/:alias - person Delete + * @api {delete} adminapi/pagans/person/:tribe/:alias - person Delete * @apiName deleteperson * @apiGroup Pagans * @apiDescription @@ -292,7 +287,7 @@ router.delete( ); /** - * @api {get} /api/adminapi/pagans/person/:alias - person Get + * @api {get} adminapi/pagans/person/:alias - person Get * @apiName getpersondata * @apiDescription Get person information from his alias for a xtribe (data and profils per apps) * @apiGroup Pagans @@ -324,7 +319,7 @@ router.get("/person/:alias", checkHeaders, isAuthenticated, (req, res) => { }); /** - * @api {put} /api/adminapi/pagans/person/:tribe - person Put + * @api {put} adminapi/pagans/person/:tribe - person Put * @apiName updateperson * @apiGroup Pagans * @apiDescription add a person = alias in tribe. xalias must be authenticated. This end point have to be use the first time a person is create then use item Update PUT /api/adminapi/odmdb/itm/:tribe/persons.
This endpoint is the only way to change profils of a person by itself (authenitcated alias = person.alias) and can be done only with req.body.addprofils req.body.removeprofils. @@ -401,13 +396,13 @@ router.put("/person/:tribe", checkHeaders, isAuthenticated, (req, res) => { }); /** - * @api {post} /api/adminapi/pagans/keyrecovery - recovery keys + * @api {post} /adminapi/pagans/keyrecovery - recovery keys * @apiName recoveryKey * @apiGroup Pagans * @apiDescription Send mails with all registers identities (one per alias where recoveryauth.email is register). Search can be request by email or by alias for a tribe. It is looking for in person.recoveryauth.email to send keys. One mail is sent by alias. So if n alias has the same recoveryaut.email then it will send n email. * @apiBody {string} emailalias type of search (email or alias) * @apiBody {string} tribe tribename into looking for - * @apiBody {string} search an email or an alias + * @apiBody {string} search a text containing email or an alias to looking for * * @apiSuccess {object} send recovery email * @apiSuccessExample {json} Success-Response: @@ -420,6 +415,9 @@ 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") { @@ -448,7 +446,7 @@ router.post("/keyrecovery", checkHeaders, (req, res) => { }); } } else { - //console later + res.status(406).json({status:406,ref:"Pagans",msg:"emailaliasnotemailoralias",data:{}}) } emailist.forEach((e) => { @@ -471,6 +469,7 @@ router.post("/keyrecovery", checkHeaders, (req, res) => { data: { tribe: req.body.tribe }, }); } + */ }); module.exports = router;