From 9651b2b3d24122d97f2f522248d7f8b8d9fda9c2 Mon Sep 17 00:00:00 2001 From: philc Date: Tue, 16 Apr 2024 15:37:33 +0200 Subject: [PATCH] fix substring --- middlewares/checkHeaders.js | 11 ++++++++++- models/Pagans.js | 4 ++-- routes/pagans.js | 30 +++--------------------------- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/middlewares/checkHeaders.js b/middlewares/checkHeaders.js index cf17f12..1da0199 100755 --- a/middlewares/checkHeaders.js +++ b/middlewares/checkHeaders.js @@ -16,7 +16,16 @@ const log = conf.api.activelog.includes(currentmod) * @apiHeader {array[]} xprofils list of string profil apply into xtribe for xapp * @apiHeader {string} xuuid a unique number uuid.v4 created the fisrt time a domain is visited on a device * @apiHeader {integer} xtrkversion a version number link to tracking system - * + * @apiHeaderExample {json} Header-Example for anonymous: + * { + * "xtrkversion":1, + * "xtribe":"smatchit", + * "xapp":"presentation", + * "xlang":"fr", + * "xalias":"anonymous", + * "xhash":"anonymous", + * "xdays":0 + * } * @apiHeaderExample {json} Header-Example: * { * Cache-Control: "no-cache", diff --git a/models/Pagans.js b/models/Pagans.js index a2bff21..afc5635 100644 --- a/models/Pagans.js +++ b/models/Pagans.js @@ -88,13 +88,13 @@ Pagans.sendmailkey = (data) => { if (log) console.log(currentmod, data.alias, "-", - data.privatekey.substring(0,10), + (data.privatekey)?data.privatekey.substring(0,10):"", "-", data.tribe, "-", data.passphrase, "-", - data.publickey.substring(0,10), + (data.publickey)? data.publickey.substring(0,10):"", "-", data.email, "-", diff --git a/routes/pagans.js b/routes/pagans.js index a57a349..fb11a71 100755 --- a/routes/pagans.js +++ b/routes/pagans.js @@ -219,7 +219,7 @@ router.delete("/alias/:alias", checkHeaders, isAuthenticated, (req, res) => { * @apiName deleteperson * @apiGroup Pagans * @apiDescription - * Unsubscribe a person to a tribe => remove a person item and all data link to this alias + * Unsubscribe a person to a tribe => remove a person item and all data link to this alias. An asynchrone process turn each day to clean data in tribe, if a persons does not exist anymore in the tribe. Pagans alias is still existing as it is autonomous. It is possible to delete pagans see "pagan Delete". * @apiHeader {array} xprofils list of profil of authenticated user * @apiHeader {string} xalias current user * @apiParam {string} tribe where person alias exist @@ -302,7 +302,7 @@ router.put("/person/:tribe", checkHeaders, isAuthenticated, (req, res) => { * HTTP/1.1 200 OK * {"status":200, "ref":"Pagans", "msg":"recoveryemailsent", "data":{email,tribe,numberemailsent'}} * - * @apiError (404) {string} emailnotfound email does not exist for this tribe + * @apiError (404) {string} recoveryemailnotfound email does not exist for this tribe * @apiErrorExample {json} * {status: 404, ref:"pagans",msg:"recoveryemailnotfound",data: { tribe,email } } * @@ -340,29 +340,5 @@ router.post("/keyrecovery", checkHeaders, (req, res) => { res.status(404).json({status:404,ref:"Pagans",msg:"recoveryemailnotfound",data:{tribe:req.body.tribe}}); } }); -/** - * @api {get} adminapi/pagans/keyrecovery/:tribe/:alias - recovery keys by alias - * @apiName recoveryKey - * @apiGroup Pagans - * @apiDescription Send to email recovery if exist key files - * - * @apiSuccess {object} send recovery mail for alias - * @apiSuccessExample {json} Success-Response: - * HTTP/1.1 200 OK - * {"status":200, "ref":"Pagans", "msg":"recoveryemailsent", "data":{email,tribe,nbalias:1, nbqent:1 or 0}} - * - * @apiError (404) {string} emailnotfound email does not exist for this tribe - * @apiErrorExample {json} - * {status: 404, ref:"pagans",msg:"emailnotfound",data: { tribe,email } } - * - */ -router.get("/keyrecovery/:tribe/:alias", checkHeaders, (req, res) => { - // a tester et revoir - const ret = Pagans.sendmailkey({alias:req.params.alias,tribe:req.params.tribe,lg:req.session.header.xlang}) - if (ret.status==200){ - return {status:200,ref:"Pagans",msg:"recoveryemailsent",data:{email:"",tribe:req.params.tribe,nbalias:1, nbsent:1}} - }else{ - return {status:404,ref:"Pagans",msg:"emailnotfound",data:{tribe:req.params.tribe,email:req.params.email}} - } -}); + module.exports = router;