From 21effdf5be1cc6baa41d2ae57e5348e453b54ef4 Mon Sep 17 00:00:00 2001 From: philc Date: Thu, 14 Nov 2024 18:47:35 +0100 Subject: [PATCH] Modif Odmdb --- apxtri/apxtri.js | 21 +++++++++++---------- apxtri/models/Odmdb.js | 2 +- apxtri/routes/notifications.js | 4 ++-- apxtri/setup/nginx.wwwscf | 18 +++++++++--------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/apxtri/apxtri.js b/apxtri/apxtri.js index 427d5cf..c5de21b 100755 --- a/apxtri/apxtri.js +++ b/apxtri/apxtri.js @@ -114,8 +114,8 @@ apxtri.setuptribe = async (tribe, conf) => { inittribe.sudoUser = process.env.USER; //check nation exist and town does not exist if ( - !fs.existsSync("../adminapi/objects/nations/idx/lst_nations.json") || - !fs.existsSync("../adminapi/objects/towns/idx/lst_towns.json") + !fs.existsSync("../adminapi/objects/nations/idx/lst_nationId.json") || + !fs.existsSync("../adminapi/objects/towns/idx/lst_townId.json") ) { console.log( `Sorry, check setup.sh process that was not able to init your adminapi/objects ` @@ -229,7 +229,7 @@ apxtri.runexpress = async (tribesdns, conf) => { const context = {}; const pathtr = path.resolve(`../${t}`); context.routes = []; - tribroutes = glob.sync(`${pathtr}/apxtri/routes/*.js`).map((f) => { + tribroutes = glob.sync(`${pathtr}/apxtri/routes/*.js`).map((f) => { const rt = `/${t}/${path.basename(f, ".js")}`; context.routes.push(rt); return { url: rt, route: f }; @@ -275,22 +275,23 @@ apxtri.runexpress = async (tribesdns, conf) => { console.log(currentmod, " app.locals.tribeids", app.locals.tribeids); // Cors management - let originlst = "test"; + let regtxt = "(test"; doms.forEach((d) => { - originlst += `|${d.replace(/\./g, "\\.")}`; + regtxt += `|${d.replace(/\./g, "\\.")}`; }); - const regtxt = `^http.?:\/\/(${originlst})`; - let cor = false; + regtxt+=")$" +// let cor = false; const regorigin = new RegExp(regtxt); app.use((req, res, next) => { - if (req.headers.origin == undefined) { + /*if (req.headers.origin == undefined) { cor = true; } else { cor = regorigin.test(req.headers.origin); - } + }*/ + const cor=regorigin.test(req.headers.origin); if (!cor) console.log( - `The domain name ${req.headers.origin} is not allow to access for CORS settings, add it in itm/tribename.json in dns` + `The domain name ${req.headers.origin} is not allow to access for CORS settings, add it in itm/tribename.json in dns current origin allow are filter by ${regtxt}` ); cors({ origin: cor, diff --git a/apxtri/models/Odmdb.js b/apxtri/models/Odmdb.js index 0aa02b8..9bfddcc 100644 --- a/apxtri/models/Odmdb.js +++ b/apxtri/models/Odmdb.js @@ -649,7 +649,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => { if (crud == "U" && accessright.U.length > 0) { itmtostore = itmold; const keynotallow = Object.keys(itm).filter( - (el) => !accessright.U.includes(el) + (el) => !(el==getschema.data.schema.apxid || accessright.U.includes(el)) ); if (keynotallow.length > 0) { feedbackinfo.keynotallow = keynotallow; diff --git a/apxtri/routes/notifications.js b/apxtri/routes/notifications.js index a5ecfc6..3bb0782 100644 --- a/apxtri/routes/notifications.js +++ b/apxtri/routes/notifications.js @@ -87,14 +87,14 @@ router.post( ); /** - * @api {POST} adminapi/notifications/registeranonymous/:tribe/:mlist/:typekey/:data -Register email||phone to mlist + * @api {POST} adminapi/notifications/registeranonymous -Register email||phone to mlist * @apiName register * @apiGroup Notifications * @apiDescription Register an email or phone into a mailinglist mlist * @apiBody {string} tribe an existing tribe * @apiBody {string} mlist a mailing list name * @apiBody {string} key email or phone keyword - * @apiBod {string} srckey must exist in tribes/schema/lg/enumtrk_xx.json + * @apiBody {string} srckey must exist in tribes/schema/lg/enumtrk_xx.json * @apiParams {string} data the email or phone value * @apiSuccess {object} update mailinglist/{mlist}.json successfull * @apiSuccessExample {json} successfullmessage diff --git a/apxtri/setup/nginx.wwwscf b/apxtri/setup/nginx.wwwscf index 5c21a2d..9a2ac11 100644 --- a/apxtri/setup/nginx.wwwscf +++ b/apxtri/setup/nginx.wwwscf @@ -4,16 +4,16 @@ add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; add_header 'Access-Control-Allow-Headers' '*' always; -# usefull to debug nginx conf 3 next line: -access_log {{{townpath}}}/{{{tribeId}}}/logs/nginx/{{{tribeId}}}_{{{website}}}.access.log main; -error_log {{{townpath}}}/{{{tribeId}}}/logs/nginx/{{{tribeId}}}_{{{website}}}.error.log debug; -add_header xdebug "testmsg debug: $uri - $request - liste args: $args - url:$arg_url - alias:$arg_alias " always; +access_log {{{townpath}}}/{{{tribeId}}}/logs/nginx/{{{website}}}.{{{tribeId}}}.{{{townId}}}.{{{nationId}}}.access.log main; +error_log {{{townpath}}}/{{{tribeId}}}/logs/nginx/{{{website}}}.{{{tribeId}}}.{{{townId}}}.{{{nationId}}}.error.log debug; +# usefull to debug nginx: +#add_header xdebug "testmsg debug: $uri - $request - liste args: $args - url:$arg_url - alias:$arg_alias " always; set $trackme 0; if ( $uri ~ ^/trk/ ){ set $trackme 1; } -access_log {{{townpath}}}/{{{tribeId}}}/logs/nginx/{{{tribeId}}}_{{{website}}}.trk.log tracker if=$trackme ; +access_log {{{townpath}}}/{{{tribeId}}}/logs/nginx/{{{website}}}.{{{tribeId}}}.{{{townId}}}.{{{nationId}}}.trk.log tracker if=$trackme ; location ~* /trk/ { if ( $uri ~ ^/trk/redirect ){ return 301 $arg_url; @@ -42,12 +42,12 @@ location /cdn/ { } location /api/ { rewrite /api/(.*$) /$1 break; - proxy_pass http://localhost:3020; + proxy_pass http://localhost:{{{apiport}}}; proxy_redirect off; include proxy_params; } location /socket/ { - proxy_pass http://127.0.0.1:3030; + proxy_pass http://127.0.0.1:{{socketport}}; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; @@ -55,7 +55,7 @@ location /socket/ { proxy_cache_bypass $http_upgrade; } location /apidoc/ { - root {{{townpath}}}/{{{tribeId}}}/objects/wwws/apidoc/; + root {{{townpath}}}/{{{tribeId}}}/objects/wwws/apidoc; index index.html; } location /src/ { @@ -64,7 +64,7 @@ location /src/ { index index.html index_fr.html index_en.html; } location / { - root {{{townpath}}}/{{{tribeId}}}/objects/wwws/{{{website}}}/dist/; + root {{{townpath}}}/{{{tribeId}}}/objects/wwws/{{{website}}}/dist; index index.html index_fr.html index_en.html; } error_page 404 /404.html;