change path
This commit is contained in:
parent
cdcab5bf38
commit
34c780d460
@ -1,3 +1,4 @@
|
|||||||
|
const path=require('path')
|
||||||
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
const conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||||
const currentmod='checkHeaders';
|
const currentmod='checkHeaders';
|
||||||
const log = conf.api.activelog.includes(currentmod)
|
const log = conf.api.activelog.includes(currentmod)
|
||||||
@ -16,7 +17,9 @@ const log = conf.api.activelog.includes(currentmod)
|
|||||||
* @apiHeader {array[]} xprofils list of string profil apply into xtribe for xapp
|
* @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 {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
|
* @apiHeader {integer} xtrkversion a version number link to tracking system
|
||||||
* @apiHeaderExample {json} Header-Example for anonymous:
|
* @apiHeaderExample {json} Headeconst conf = require(`../../../adminapi/objects/tribes/itm/adminapi.json`);
|
||||||
|
const currentmod='checkHeaders';
|
||||||
|
const log = conf.api.activelog.includes(currentmod)r-Example for anonymous:
|
||||||
* {
|
* {
|
||||||
* "xtrkversion":1,
|
* "xtrkversion":1,
|
||||||
* "xtribe":"smatchit",
|
* "xtribe":"smatchit",
|
||||||
|
@ -38,18 +38,18 @@ const isAuthenticated = async (req, res, next) => {
|
|||||||
if (fs.existsSync('../tmp/tokens')) console.log('pass B')
|
if (fs.existsSync('../tmp/tokens')) console.log('pass B')
|
||||||
*/
|
*/
|
||||||
const currentday = dayjs().date();
|
const currentday = dayjs().date();
|
||||||
fs.ensureDirSync(`../tmp/tokens`);
|
fs.ensureDirSync(`../adminapi/tmp/tokens`);
|
||||||
let menagedone = fs.existsSync(
|
let menagedone = fs.existsSync(
|
||||||
`../../tmp/tokens/menagedone${currentday}`
|
`../adminapi/tmp/tokens/menagedone${currentday}`
|
||||||
);
|
);
|
||||||
if (menagedone) console.log(Date.now(),`menagedone${currentday} was it done today?:${menagedone}`);
|
if (menagedone) console.log(Date.now(),`menagedone${currentday} was it done today?:${menagedone}`);
|
||||||
if (!menagedone) {
|
if (!menagedone) {
|
||||||
// clean oldest
|
// clean oldest
|
||||||
const tsday = dayjs().valueOf(); // now in timestamp format
|
const tsday = dayjs().valueOf(); // now in timestamp format
|
||||||
glob.sync(`../../tmp/tokens/menagedone*`).forEach((f) => {
|
glob.sync(`../adminapi/tmp/tokens/menagedone*`).forEach((f) => {
|
||||||
fs.removeSync(f);
|
fs.removeSync(f);
|
||||||
});
|
});
|
||||||
glob.sync(`../../tmp/tokens/*.json`).forEach((f) => {
|
glob.sync(`../adminapi/tmp/tokens/*.json`).forEach((f) => {
|
||||||
const fsplit = f.split("_");
|
const fsplit = f.split("_");
|
||||||
const elapse = tsday - parseInt(fsplit[2]);
|
const elapse = tsday - parseInt(fsplit[2]);
|
||||||
//24h 86400000 milliseconde 15mn 900000
|
//24h 86400000 milliseconde 15mn 900000
|
||||||
@ -58,11 +58,11 @@ const isAuthenticated = async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//clean tmp
|
//clean tmp
|
||||||
glob.sync(`../../tmp/*.txt`).forEach((f) => {
|
glob.sync(`../adminapi/tmp/*.txt`).forEach((f) => {
|
||||||
fs.remove(f);
|
fs.remove(f);
|
||||||
});
|
});
|
||||||
fs.outputFile(
|
fs.outputFile(
|
||||||
`../../tmp/tokens/menagedone${currentday}`,
|
`../adminapi/tmp/tokens/menagedone${currentday}`,
|
||||||
"done by middleware/isAUthenticated"
|
"done by middleware/isAUthenticated"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ const isAuthenticated = async (req, res, next) => {
|
|||||||
return res.status(resnotauth.status).json(resnotauth);
|
return res.status(resnotauth.status).json(resnotauth);
|
||||||
}
|
}
|
||||||
|
|
||||||
let tmpfs = `../../tmp/tokens/${req.session.header.xalias}_${req.session.header.xtribe}_${req.session.header.xdays}`;
|
let tmpfs = `../adminapi/tmp/tokens/${req.session.header.xalias}_${req.session.header.xtribe}_${req.session.header.xdays}`;
|
||||||
//max filename in ext4: 255 characters
|
//max filename in ext4: 255 characters
|
||||||
tmpfs += `_${req.session.header.xhash.substring(
|
tmpfs += `_${req.session.header.xhash.substring(
|
||||||
150,
|
150,
|
||||||
@ -97,7 +97,7 @@ const isAuthenticated = async (req, res, next) => {
|
|||||||
const sleep = (ms) => {
|
const sleep = (ms) => {
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
};
|
};
|
||||||
const failstamp = `../../tmp/tokens/${alias}.json`;
|
const failstamp = `../adminapi/tmp/tokens/${alias}.json`;
|
||||||
if (action == "clean") {
|
if (action == "clean") {
|
||||||
//to reinit bruteforce checker
|
//to reinit bruteforce checker
|
||||||
if (log) console.log(currentmod, "try to clean penalty file ", failstamp);
|
if (log) console.log(currentmod, "try to clean penalty file ", failstamp);
|
||||||
@ -119,7 +119,7 @@ const isAuthenticated = async (req, res, next) => {
|
|||||||
if (!fs.existsSync(tmpfs)) {
|
if (!fs.existsSync(tmpfs)) {
|
||||||
// need to check detached sign
|
// need to check detached sign
|
||||||
let publickey = "";
|
let publickey = "";
|
||||||
const aliasinfo = `../objects/pagans/itm/${req.session.header.xalias}.json`;
|
const aliasinfo = `../adminapi/objects/pagans/itm/${req.session.header.xalias}.json`;
|
||||||
if (fs.existsSync(aliasinfo)) {
|
if (fs.existsSync(aliasinfo)) {
|
||||||
publickey = fs.readJsonSync(aliasinfo).publickey;
|
publickey = fs.readJsonSync(aliasinfo).publickey;
|
||||||
} else if (req.body.publickey) {
|
} else if (req.body.publickey) {
|
||||||
@ -183,7 +183,7 @@ const isAuthenticated = async (req, res, next) => {
|
|||||||
return res.status(resnotauth.status).send(resnotauth);
|
return res.status(resnotauth.status).send(resnotauth);
|
||||||
}
|
}
|
||||||
// authenticated then get person profils (person = pagan for a xtrib)
|
// authenticated then get person profils (person = pagan for a xtrib)
|
||||||
const person = `../../${req.session.header.xtribe}/objects/persons/itm/${req.session.header.xalias}.json`;
|
const person = `../${req.session.header.xtribe}/objects/persons/itm/${req.session.header.xalias}.json`;
|
||||||
if (log) console.log(currentmod,"Profils tribe/app management");
|
if (log) console.log(currentmod,"Profils tribe/app management");
|
||||||
if (log) console.log(currentmod,"person", person);
|
if (log) console.log(currentmod,"person", person);
|
||||||
if (fs.existsSync(person)) {
|
if (fs.existsSync(person)) {
|
||||||
|
@ -19,7 +19,7 @@ const log = conf.api.activelog.includes(currentmod);
|
|||||||
const Notifications = {};
|
const Notifications = {};
|
||||||
|
|
||||||
Notifications.get = (alias, tribeId) => {
|
Notifications.get = (alias, tribeId) => {
|
||||||
const notiffile = `../../${req.params.tribeId}/notifications/${req.params.alias}.json`;
|
const notiffile = `../${req.params.tribe}/notifications/${req.params.alias}.json`;
|
||||||
const msg = fs.existsSync(notiffile) ? fs.readJSONSync(notiffile) : {};
|
const msg = fs.existsSync(notiffile) ? fs.readJSONSync(notiffile) : {};
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
@ -34,7 +34,7 @@ Notifications.get = (alias, tribeId) => {
|
|||||||
Notifications.statmaillist = (tribe) => {
|
Notifications.statmaillist = (tribe) => {
|
||||||
const statinfo = {};
|
const statinfo = {};
|
||||||
let csv = "email/phone;name;srckey\n";
|
let csv = "email/phone;name;srckey\n";
|
||||||
const src = `../../${tribe}/objects/maillinglists/*.json`;
|
const src = `../${tribe}/objects/maillinglists/*.json`;
|
||||||
console.log(path.resolve(src));
|
console.log(path.resolve(src));
|
||||||
glob.sync(src).forEach((f) => {
|
glob.sync(src).forEach((f) => {
|
||||||
const name = path.basename(f, ".json");
|
const name = path.basename(f, ".json");
|
||||||
@ -49,7 +49,7 @@ Notifications.statmaillist = (tribe) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
// fichier csv stocker en local en attendant d'avoir un back pour stocker la reponse dans data.csv
|
// fichier csv stocker en local en attendant d'avoir un back pour stocker la reponse dans data.csv
|
||||||
fs.outputFileSync(`../../${tribe}/mailinglst.csv`, csv, "utf-8");
|
fs.outputFileSync(`../${tribe}/mailinglst.csv`, csv, "utf-8");
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
ref: "Notifications",
|
ref: "Notifications",
|
||||||
@ -73,7 +73,7 @@ Notifications.registertolist = (key, typekey, tribe, mlist, srckey, uuid) => {
|
|||||||
data: { fielderr: typekey, format: typekey },
|
data: { fielderr: typekey, format: typekey },
|
||||||
};
|
};
|
||||||
|
|
||||||
const destin = `../../${tribe}/objects/maillinglists/${typekey}_${mlist}.json`;
|
const destin = `../${tribe}/objects/maillinglists/${typekey}_${mlist}.json`;
|
||||||
if (!fs.existsSync(destin)) {
|
if (!fs.existsSync(destin)) {
|
||||||
console.log(
|
console.log(
|
||||||
`######## Attention tentative d'ecriture non autorisé,le fichier n'existe pas ${destin} créer le à la main vide {}`
|
`######## Attention tentative d'ecriture non autorisé,le fichier n'existe pas ${destin} créer le à la main vide {}`
|
||||||
@ -153,9 +153,9 @@ Notifications.sendsms = async (data, tribeId) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
let confsms = conf.sms;
|
let confsms = conf.sms;
|
||||||
if (fs.existsSync(`../../adminapi/objects/tribes/itm/${req.session.header.xtribe}.json`)) {
|
if (fs.existsSync(`../adminapi/objects/tribes/itm/${req.session.header.xtribe}.json`)) {
|
||||||
const conftrib = fs.readJSONSync(
|
const conftrib = fs.readJSONSync(
|
||||||
`../../adminapi/objects/tribes/itm/${req.session.header.xtribe}.json`
|
`../adminapi/objects/tribes/itm/${req.session.header.xtribe}.json`
|
||||||
);
|
);
|
||||||
if (conftrib.sms) confsms = conftrib.sms;
|
if (conftrib.sms) confsms = conftrib.sms;
|
||||||
}
|
}
|
||||||
@ -332,7 +332,7 @@ Notifications.sendmail = async (data, tribe) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
let confsmtp = conf.smtp;
|
let confsmtp = conf.smtp;
|
||||||
const conftribfile = `../../adminapi/objects/tribes/itm/${tribe}.json`;
|
const conftribfile = `../adminapi/objects/tribes/itm/${tribe}.json`;
|
||||||
if (fs.existsSync(conftribfile)) {
|
if (fs.existsSync(conftribfile)) {
|
||||||
const conftrib = fs.readJSONSync(conftribfile);
|
const conftrib = fs.readJSONSync(conftribfile);
|
||||||
if (!conftrib.emailcontact){
|
if (!conftrib.emailcontact){
|
||||||
|
@ -32,7 +32,7 @@ const Pagans = {};
|
|||||||
Pagans.logout = (alias, tribe, xdays, xhash) => {
|
Pagans.logout = (alias, tribe, xdays, xhash) => {
|
||||||
//console.log(alias, tribe, xdays, xhash);
|
//console.log(alias, tribe, xdays, xhash);
|
||||||
// inline with middleware isAuthenticated.js
|
// inline with middleware isAuthenticated.js
|
||||||
let tmpfs = `../../tmp/tokens/${alias}_${tribe}_${xdays}`;
|
let tmpfs = `../adminapi/tmp/tokens/${alias}_${tribe}_${xdays}`;
|
||||||
//max filename in ext4: 255 characters
|
//max filename in ext4: 255 characters
|
||||||
tmpfs += `_${xhash.substring(150, 150 + tmpfs.length - 249)}.json`;
|
tmpfs += `_${xhash.substring(150, 150 + tmpfs.length - 249)}.json`;
|
||||||
fs.remove(tmpfs);
|
fs.remove(tmpfs);
|
||||||
@ -69,7 +69,7 @@ Pagans.keyrecovery = (emailalias, tribe, search, lg) => {
|
|||||||
let emaillist = [];
|
let emaillist = [];
|
||||||
if (emailalias == "email") {
|
if (emailalias == "email") {
|
||||||
search = search.toLowerCase();
|
search = search.toLowerCase();
|
||||||
const idxreco = `../../${tribe}/objects/persons/idx/emailrecovery_alias.json`;
|
const idxreco = `../${tribe}/objects/persons/idx/emailrecovery_alias.json`;
|
||||||
if (fs.existsSync(idxreco)) {
|
if (fs.existsSync(idxreco)) {
|
||||||
const emailreco = fs.readJSONSync(idxreco);
|
const emailreco = fs.readJSONSync(idxreco);
|
||||||
const listalias = emailreco[search] ? emailreco[search] : [];
|
const listalias = emailreco[search] ? emailreco[search] : [];
|
||||||
@ -78,7 +78,7 @@ Pagans.keyrecovery = (emailalias, tribe, search, lg) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const personpath = `../../${tribe}/objects/persons/itm/${search}.json`;
|
const personpath = `../${tribe}/objects/persons/itm/${search}.json`;
|
||||||
|
|
||||||
if (fs.existsSync(personpath)) {
|
if (fs.existsSync(personpath)) {
|
||||||
const person = fs.readJSONSync(personpath);
|
const person = fs.readJSONSync(personpath);
|
||||||
@ -170,7 +170,7 @@ Pagans.sendmailkey = (data) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!data.publickey || !data.email || !data.privatekey) {
|
if (!data.publickey || !data.email || !data.privatekey) {
|
||||||
const personfile = `../../${data.tribe}/objects/persons/itm/${data.alias}.json`;
|
const personfile = `../${data.tribe}/objects/persons/itm/${data.alias}.json`;
|
||||||
if (!fs.existsSync(personfile)) {
|
if (!fs.existsSync(personfile)) {
|
||||||
return {
|
return {
|
||||||
status: 404,
|
status: 404,
|
||||||
@ -198,7 +198,7 @@ Pagans.sendmailkey = (data) => {
|
|||||||
person.publickey = data.publickey;
|
person.publickey = data.publickey;
|
||||||
}
|
}
|
||||||
person.avecpassphrase = person.passphrase != "";
|
person.avecpassphrase = person.passphrase != "";
|
||||||
let tplfile = `../../${data.tribe}/template/createidentity_${data.lg}.js`;
|
let tplfile = `../${data.tribe}/template/createidentity_${data.lg}.js`;
|
||||||
if (!fs.existsSync(tplfile)) {
|
if (!fs.existsSync(tplfile)) {
|
||||||
tplfile = `../template/createidentity_${data.lg}.js`;
|
tplfile = `../template/createidentity_${data.lg}.js`;
|
||||||
if (!fs.existsSync(tplfile)) {
|
if (!fs.existsSync(tplfile)) {
|
||||||
|
@ -10,7 +10,7 @@ const Wwws = {};
|
|||||||
Wwws.initlocalwco=(tribwco,profils,lg)=>{
|
Wwws.initlocalwco=(tribwco,profils,lg)=>{
|
||||||
const wco={}
|
const wco={}
|
||||||
Object.keys(tribwco).forEach(t=>{
|
Object.keys(tribwco).forEach(t=>{
|
||||||
if (!fs.existsSync(`../../../${tribwco}`)){}
|
if (!fs.existsSync(`../${tribwco}`)){}
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ Wwws.initlocalwco=(tribwco,profils,lg)=>{
|
|||||||
|
|
||||||
Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
||||||
const fileparam = `../${tribe}/objects/wwws/itm/${appname}.json`;
|
const fileparam = `../${tribe}/objects/wwws/itm/${appname}.json`;
|
||||||
console.log(path.resolve(fileparam));
|
//console.log(path.resolve(fileparam));
|
||||||
if (!fs.existsSync(fileparam)) {
|
if (!fs.existsSync(fileparam)) {
|
||||||
return { status: 404, ref: "Wwws", msg: "appdoesnotexist", data: {} };
|
return { status: 404, ref: "Wwws", msg: "appdoesnotexist", data: {} };
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
//check version
|
//check version
|
||||||
const initname = `../tmp/initlocaldata/${tribe}_${appname}_${pagename}_${lg}_${locals.pages[pagename].version}.json`;
|
const initname = `../${tribe}/tmp/initlocaldata/${tribe}_${appname}_${pagename}_${lg}_${locals.pages[pagename].version}.json`;
|
||||||
if (fs.existsSync(initname) && 1 != 1) {
|
if (fs.existsSync(initname) && 1 != 1) {
|
||||||
const init = fs.readJsonSync(initname);
|
const init = fs.readJsonSync(initname);
|
||||||
if (init.app.version == locals.app.version) {
|
if (init.app.version == locals.app.version) {
|
||||||
@ -82,9 +82,7 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
|||||||
const loc = locals.pages[pagename];
|
const loc = locals.pages[pagename];
|
||||||
if (loc.itms){
|
if (loc.itms){
|
||||||
Object.keys(loc.itms).forEach((r) => {
|
Object.keys(loc.itms).forEach((r) => {
|
||||||
const src = `${loc.itms[r]}.json`;
|
const src = `../${loc.itms[r]}.json`;
|
||||||
console.log(path.resolve(src))
|
|
||||||
console.log(path.resolve(`${loc.itms[r]}.json`))
|
|
||||||
if (fs.existsSync(src)) {
|
if (fs.existsSync(src)) {
|
||||||
localstorage.itms[r] = fs.readJSONSync(src);
|
localstorage.itms[r] = fs.readJSONSync(src);
|
||||||
} else {
|
} else {
|
||||||
@ -94,7 +92,7 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
|||||||
}
|
}
|
||||||
if (loc.ref) {
|
if (loc.ref) {
|
||||||
Object.keys(loc.ref).forEach((r) => {
|
Object.keys(loc.ref).forEach((r) => {
|
||||||
const src = `${loc.ref[r]}_${lg}.json`;
|
const src = `../${loc.ref[r]}_${lg}.json`;
|
||||||
if (fs.existsSync(src)) {
|
if (fs.existsSync(src)) {
|
||||||
localstorage.ref[r] = fs.readJSONSync(src);
|
localstorage.ref[r] = fs.readJSONSync(src);
|
||||||
} else {
|
} else {
|
||||||
@ -106,7 +104,10 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
|||||||
}
|
}
|
||||||
if (loc.options) {
|
if (loc.options) {
|
||||||
Object.keys(loc.options).forEach((r) => {
|
Object.keys(loc.options).forEach((r) => {
|
||||||
const src = `${loc.options[r]}_${lg}.json`;
|
|
||||||
|
const src = `../${loc.options[r]}_${lg}.json`;
|
||||||
|
//console.log(path.resolve(src))
|
||||||
|
|
||||||
if (fs.existsSync(src)) {
|
if (fs.existsSync(src)) {
|
||||||
localstorage.options[r] = fs.readJSONSync(src);
|
localstorage.options[r] = fs.readJSONSync(src);
|
||||||
} else {
|
} else {
|
||||||
@ -127,8 +128,8 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
|||||||
}
|
}
|
||||||
if (loc.tpl) {
|
if (loc.tpl) {
|
||||||
Object.keys(loc.tpl).forEach((r) => {
|
Object.keys(loc.tpl).forEach((r) => {
|
||||||
let src = `${loc.tpl[r]}`;
|
let src = `../${loc.tpl[r]}`;
|
||||||
console.log(path.resolve(src))
|
//console.log(path.resolve(src))
|
||||||
if (!fs.existsSync(src)) {
|
if (!fs.existsSync(src)) {
|
||||||
src += `_${lg}.mustache`;
|
src += `_${lg}.mustache`;
|
||||||
}
|
}
|
||||||
@ -143,8 +144,8 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
|||||||
}
|
}
|
||||||
if (loc.tpldata) {
|
if (loc.tpldata) {
|
||||||
Object.keys(loc.tpldata).forEach((r) => {
|
Object.keys(loc.tpldata).forEach((r) => {
|
||||||
let src = `${loc.tpldata[r]}`;
|
let src = `../${loc.tpldata[r]}`;
|
||||||
console.log(path.resolve(src))
|
//console.log(path.resolve(src))
|
||||||
if (!fs.existsSync(src)) {
|
if (!fs.existsSync(src)) {
|
||||||
src += `_${lg}.json`;
|
src += `_${lg}.json`;
|
||||||
}
|
}
|
||||||
@ -160,11 +161,11 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => {
|
|||||||
if (loc.schema) {
|
if (loc.schema) {
|
||||||
loc.schema.forEach((objpath) => {
|
loc.schema.forEach((objpath) => {
|
||||||
const name = path.basename(objpath);
|
const name = path.basename(objpath);
|
||||||
const schema = Odmdb.Schema(`../../${objpath}`, false, lg);
|
const schema = Odmdb.Schema(`../${objpath}`, false, lg);
|
||||||
if (schema.status == 200) {
|
if (schema.status == 200) {
|
||||||
localstorage.schema[name] = schema.data.schema;
|
localstorage.schema[name] = schema.data.schema;
|
||||||
} else {
|
} else {
|
||||||
console.log(schema);
|
//console.log(schema);
|
||||||
let msg=`Check your ${fileparam} for schema in ${pagename}, for ${schema.status} ${schema.ref} ${schema.msg} :`
|
let msg=`Check your ${fileparam} for schema in ${pagename}, for ${schema.status} ${schema.ref} ${schema.msg} :`
|
||||||
if (schema.status==406){
|
if (schema.status==406){
|
||||||
if (schema.msg) msg+=schema.msg
|
if (schema.msg) msg+=schema.msg
|
||||||
|
@ -76,7 +76,7 @@ router.post(
|
|||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const data = req.body.data;
|
const data = req.body.data;
|
||||||
data.emailsto = req.body.emails;
|
data.emailsto = req.body.emails;
|
||||||
const pathtpl = `../../${req.params.tribe}/template/${req.params.template}_${req.session.header.xlang}.js`;
|
const pathtpl = `../${req.params.tribe}/template/${req.params.template}_${req.session.header.xlang}.js`;
|
||||||
const sendemail = await Notifications.manageemail(
|
const sendemail = await Notifications.manageemail(
|
||||||
data,
|
data,
|
||||||
pathtpl,
|
pathtpl,
|
||||||
|
@ -57,7 +57,7 @@ router.get(
|
|||||||
checkHeaders,
|
checkHeaders,
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
const objectPathname = `../../${req.params.tribe}/objects/${req.params.objectname}`;
|
const objectPathname = `../${req.params.tribe}/objects/${req.params.objectname}`;
|
||||||
console.log(objectPathname);
|
console.log(objectPathname);
|
||||||
const retschema = Odmdb.Schema(objectPathname, true, req.header.xlang);
|
const retschema = Odmdb.Schema(objectPathname, true, req.header.xlang);
|
||||||
res.status(retschema.status).json(retschema);
|
res.status(retschema.status).json(retschema);
|
||||||
@ -82,7 +82,7 @@ router.get(
|
|||||||
checkHeaders,
|
checkHeaders,
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
const objectPathname = `../../${req.params.tribe}/objects/options/${req.params.optionname}_${req.header.xlang}.json`;
|
const objectPathname = `../${req.params.tribe}/objects/options/${req.params.optionname}_${req.header.xlang}.json`;
|
||||||
if (fs.existsSync(objectPathname)) {
|
if (fs.existsSync(objectPathname)) {
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
status: 200,
|
status: 200,
|
||||||
@ -128,7 +128,7 @@ router.get(
|
|||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
console.log("passe");
|
console.log("passe");
|
||||||
const indexpath = `../../${req.params.tribe}/objects/${req.params.objectname}/idx/${req.params.indexname}`;
|
const indexpath = `../${req.params.tribe}/objects/${req.params.objectname}/idx/${req.params.indexname}`;
|
||||||
console.log(indexpath);
|
console.log(indexpath);
|
||||||
if (fs.existsSync(indexpath)) {
|
if (fs.existsSync(indexpath)) {
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
@ -176,7 +176,7 @@ router.get(
|
|||||||
console.log("reindex");
|
console.log("reindex");
|
||||||
// check validity and accessright
|
// check validity and accessright
|
||||||
|
|
||||||
const objectPathname = `../../${req.params.tribe}/objects/${req.params.objectname}`;
|
const objectPathname = `../${req.params.tribe}/objects/${req.params.objectname}`;
|
||||||
if (!fs.existsSync(objectPathname)) {
|
if (!fs.existsSync(objectPathname)) {
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
status: 404,
|
status: 404,
|
||||||
@ -249,7 +249,7 @@ router.post(
|
|||||||
(req, res) => {
|
(req, res) => {
|
||||||
// Create an item of an object with no specificities
|
// Create an item of an object with no specificities
|
||||||
// if specificities then create a route / model that import odmdb
|
// if specificities then create a route / model that import odmdb
|
||||||
const objectPathname = `../../${req.params.tribe}/objects/${req.params.objectname}`;
|
const objectPathname = `../${req.params.tribe}/objects/${req.params.objectname}`;
|
||||||
const postitm = Odmdb.cud(objectPathname, "C", req.body, {
|
const postitm = Odmdb.cud(objectPathname, "C", req.body, {
|
||||||
xprofils: req.session.header.xprofils,
|
xprofils: req.session.header.xprofils,
|
||||||
xalias: req.session.header.xalias,
|
xalias: req.session.header.xalias,
|
||||||
@ -292,7 +292,7 @@ router.put(
|
|||||||
(req, res) => {
|
(req, res) => {
|
||||||
// Create an item of an object with no specificities
|
// Create an item of an object with no specificities
|
||||||
// if specificities then create a route / model that import odmdb
|
// if specificities then create a route / model that import odmdb
|
||||||
const objectPathname = `../../${req.params.tribe}/objects/${req.params.objectname}`;
|
const objectPathname = `../${req.params.tribe}/objects/${req.params.objectname}`;
|
||||||
const postitm = Odmdb.cud(objectPathname, "U", req.body, {
|
const postitm = Odmdb.cud(objectPathname, "U", req.body, {
|
||||||
xprofils: req.session.header.xprofils,
|
xprofils: req.session.header.xprofils,
|
||||||
xalias: req.session.header.xalias,
|
xalias: req.session.header.xalias,
|
||||||
@ -334,7 +334,7 @@ router.delete(
|
|||||||
(req, res) => {
|
(req, res) => {
|
||||||
// Create an item of an object with no specificities
|
// Create an item of an object with no specificities
|
||||||
// if specificities then create a route / model that import odmdb
|
// if specificities then create a route / model that import odmdb
|
||||||
const objectPathname = `../../${req.params.tribe}/objects/${req.params.objectname}`;
|
const objectPathname = `../${req.params.tribe}/objects/${req.params.objectname}`;
|
||||||
const itmtoremove={}
|
const itmtoremove={}
|
||||||
itmtoremove[req.params.apxid]=req.params.primaryid;
|
itmtoremove[req.params.apxid]=req.params.primaryid;
|
||||||
const delitm = Odmdb.cud(objectPathname, "D", itmtoremove, {
|
const delitm = Odmdb.cud(objectPathname, "D", itmtoremove, {
|
||||||
@ -376,7 +376,7 @@ router.post(
|
|||||||
checkHeaders,
|
checkHeaders,
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
const objectPathname = `../../${req.params.tribe}/objects/${req.params.objectname}`;
|
const objectPathname = `../${req.params.tribe}/objects/${req.params.objectname}`;
|
||||||
const ressearch = Odmdb.search(objectPathname, req.body, {
|
const ressearch = Odmdb.search(objectPathname, req.body, {
|
||||||
xprofils: req.session.header.xprofils,
|
xprofils: req.session.header.xprofils,
|
||||||
xalias: req.session.header.xalias,
|
xalias: req.session.header.xalias,
|
||||||
@ -410,11 +410,11 @@ router.get(
|
|||||||
checkHeaders,
|
checkHeaders,
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
const objectpath = `../../${req.params.tribe}/objects/${req.params.objectname}/itm/${req.params.primaryindex}.json`;
|
const objectpath = `../${req.params.tribe}/objects/${req.params.objectname}/itm/${req.params.primaryindex}.json`;
|
||||||
|
|
||||||
if (fs.existsSync(objectpath)) {
|
if (fs.existsSync(objectpath)) {
|
||||||
const readobj = Odmdb.r(
|
const readobj = Odmdb.r(
|
||||||
`../../${req.params.tribe}/objects/${req.params.objectname}`,
|
`../${req.params.tribe}/objects/${req.params.objectname}`,
|
||||||
req.params.primaryindex,
|
req.params.primaryindex,
|
||||||
{
|
{
|
||||||
xprofils: req.session.header.xprofils,
|
xprofils: req.session.header.xprofils,
|
||||||
|
@ -143,8 +143,8 @@ router.post("/", checkHeaders, isAuthenticated, async (req, res) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const objpagan = { alias: req.body.alias, publickey: req.body.publickey };
|
const objpagan = { alias: req.body.alias, publickey: req.body.publickey };
|
||||||
console.log(path.resolve(`../objects/pagans`));
|
console.log(path.resolve(`../adminapi/objects/pagans`));
|
||||||
const newpagan = Odmdb.cud(`../objects/pagans`, "C", objpagan, role);
|
const newpagan = Odmdb.cud(`../adminapi/objects/pagans`, "C", objpagan, role);
|
||||||
const createprocess = {
|
const createprocess = {
|
||||||
status: 200,
|
status: 200,
|
||||||
ref: "Pagans",
|
ref: "Pagans",
|
||||||
@ -183,7 +183,7 @@ router.post("/", checkHeaders, isAuthenticated, async (req, res) => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
const personup = Odmdb.cud(
|
const personup = Odmdb.cud(
|
||||||
`../../${req.body.trustedtribe}/objects/persons`,
|
`../${req.body.trustedtribe}/objects/persons`,
|
||||||
"C",
|
"C",
|
||||||
persondata,
|
persondata,
|
||||||
{ xprofils: ["anonymous", "pagans"], xalias: req.body.alias }
|
{ xprofils: ["anonymous", "pagans"], xalias: req.body.alias }
|
||||||
@ -219,7 +219,7 @@ router.post("/", checkHeaders, isAuthenticated, async (req, res) => {
|
|||||||
* Delete an alias and his publickey, this mean that publickey disapear as well as alias. We set dt_delete
|
* Delete an alias and his publickey, this mean that publickey disapear as well as alias. We set dt_delete
|
||||||
* */
|
* */
|
||||||
router.delete("/alias/:alias", checkHeaders, isAuthenticated, (req, res) => {
|
router.delete("/alias/:alias", checkHeaders, isAuthenticated, (req, res) => {
|
||||||
const personpath = `../objects/pagans`;
|
const personpath = `../adminapi/objects/pagans`;
|
||||||
const role = {
|
const role = {
|
||||||
xalias: req.session.header.xalias,
|
xalias: req.session.header.xalias,
|
||||||
xprofils: req.session.header.xprofils,
|
xprofils: req.session.header.xprofils,
|
||||||
@ -263,7 +263,7 @@ router.delete(
|
|||||||
checkHeaders,
|
checkHeaders,
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
const personpath = `../../${req.params.tribe}/objects/persons`;
|
const personpath = `../${req.params.tribe}/objects/persons`;
|
||||||
const role = {
|
const role = {
|
||||||
xalias: req.session.header.xalias,
|
xalias: req.session.header.xalias,
|
||||||
xprofils: req.session.header.xprofils,
|
xprofils: req.session.header.xprofils,
|
||||||
@ -308,10 +308,10 @@ router.delete(
|
|||||||
* */
|
* */
|
||||||
router.get("/person/:alias", checkHeaders, isAuthenticated, (req, res) => {
|
router.get("/person/:alias", checkHeaders, isAuthenticated, (req, res) => {
|
||||||
console.log(
|
console.log(
|
||||||
path.resolve(`../../${req.session.header.xtribe}/objects/persons`)
|
path.resolve(`../${req.session.header.xtribe}/objects/persons`)
|
||||||
);
|
);
|
||||||
const getperson = Odmdb.r(
|
const getperson = Odmdb.r(
|
||||||
`../../${req.session.header.xtribe}/objects/persons`,
|
`../${req.session.header.xtribe}/objects/persons`,
|
||||||
req.params.alias,
|
req.params.alias,
|
||||||
{ xprofils: req.session.header.xprofils, xalias: req.session.header.xalias }
|
{ xprofils: req.session.header.xprofils, xalias: req.session.header.xalias }
|
||||||
);
|
);
|
||||||
@ -333,7 +333,7 @@ router.get("/person/:alias", checkHeaders, isAuthenticated, (req, res) => {
|
|||||||
*/
|
*/
|
||||||
router.put("/person/:tribe", checkHeaders, isAuthenticated, (req, res) => {
|
router.put("/person/:tribe", checkHeaders, isAuthenticated, (req, res) => {
|
||||||
//console.log(req.body);
|
//console.log(req.body);
|
||||||
const pathobj = `../../${req.params.tribe}/objects/persons`;
|
const pathobj = `../${req.params.tribe}/objects/persons`;
|
||||||
const action = fs.existsSync(`${pathobj}/itm/${req.body.alias}.json`)
|
const action = fs.existsSync(`${pathobj}/itm/${req.body.alias}.json`)
|
||||||
? "U"
|
? "U"
|
||||||
: "C";
|
: "C";
|
||||||
@ -362,7 +362,7 @@ router.put("/person/:tribe", checkHeaders, isAuthenticated, (req, res) => {
|
|||||||
(e) => e !== req.body.removeprofils
|
(e) => e !== req.body.removeprofils
|
||||||
);
|
);
|
||||||
Odmdb.cud(
|
Odmdb.cud(
|
||||||
`../../${req.params.tribe}/objects/${req.body.removeprofils}`,
|
`../${req.params.tribe}/objects/${req.body.removeprofils}`,
|
||||||
"D",
|
"D",
|
||||||
{ alias: req.body.alias },
|
{ alias: req.body.alias },
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ router.get('/config/:tribe', checkHeaders,isAuthenticated,(req,res)=>{
|
|||||||
req.session.header.accessrights.data[ req.params.tribe ].tribeid.includes( 'R' )
|
req.session.header.accessrights.data[ req.params.tribe ].tribeid.includes( 'R' )
|
||||||
*/
|
*/
|
||||||
if("authorize"=="authorize"){
|
if("authorize"=="authorize"){
|
||||||
const tribconf=`../../adminapi/objects/tribes/itm/${req.params.tribe}.json`
|
const tribconf=`../adminapi/objects/tribes/itm/${req.params.tribe}.json`
|
||||||
if (!fs.existsSync(tribconf)){
|
if (!fs.existsSync(tribconf)){
|
||||||
res.status(404).json({status:404,ref:"Tribes",msg:"tribedoesnotexist", data:{tribe:req.params.tribe}})
|
res.status(404).json({status:404,ref:"Tribes",msg:"tribedoesnotexist", data:{tribe:req.params.tribe}})
|
||||||
}else{
|
}else{
|
||||||
|
@ -137,7 +137,7 @@ router.get(
|
|||||||
*/
|
*/
|
||||||
router.get("/buildpage/:tribe/:appname/:pagename", checkHeaders, (req, res) => {
|
router.get("/buildpage/:tribe/:appname/:pagename", checkHeaders, (req, res) => {
|
||||||
console.log("pass get version localstorage");
|
console.log("pass get version localstorage");
|
||||||
const localdbf = `../../${req.params.tribe}/objects/wwws/itm/${req.params.appname}`;
|
const localdbf = `../${req.params.tribe}/objects/wwws/itm/${req.params.appname}`;
|
||||||
if (!existsSync(localdbf)) {
|
if (!existsSync(localdbf)) {
|
||||||
return res
|
return res
|
||||||
.status(404)
|
.status(404)
|
||||||
|
Loading…
Reference in New Issue
Block a user