forked from apxtri/apxtri
fix get itm accessright
This commit is contained in:
parent
3e8c5b3d74
commit
b58e31c5c2
@ -438,7 +438,10 @@ 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";
|
||||
@ -494,9 +497,15 @@ Odmdb.r = (objectPathname, apxid, role) => {
|
||||
};
|
||||
}
|
||||
const data = {};
|
||||
accessright.R.forEach((p) => {
|
||||
const allowedkey =
|
||||
accessright.R.length == 0
|
||||
? Object.keys(getschema.data.schema.properties)
|
||||
: accessright.R;
|
||||
|
||||
allowedkey.forEach((p) => {
|
||||
data[p] = itm[p];
|
||||
});
|
||||
|
||||
return { status: 200, ref: "Odmdb", msg: "profilallow", data };
|
||||
};
|
||||
|
||||
@ -663,7 +672,10 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
||||
//Manage base64 case image to convert ans store in webp
|
||||
if (k.includes("imgbase64_") && itmtostore[k] != "") {
|
||||
fs.ensureDirSync(`${objectPathname}/img/`);
|
||||
const imgb64 = itmtostore[k].replace(/^data:image\/(png|png|gif|bmp|jpg|jpeg);base64,/,"");//.replace(/\+/g," ");
|
||||
const imgb64 = itmtostore[k].replace(
|
||||
/^data:image\/(png|png|gif|bmp|jpg|jpeg);base64,/,
|
||||
""
|
||||
); //.replace(/\+/g," ");
|
||||
const extension = itmtostore[k].split(";base64,")[0].split("/")[1];
|
||||
const newk = k.split("_").slice(1).join("_");
|
||||
const filenameimg = `/img/${
|
||||
@ -682,7 +694,9 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
||||
//const buf = Buffer.from(itmtostore[k], 'base64');
|
||||
//const imgwebp = await webp.bufferToWebp(buf);
|
||||
//@TODO use sharp to resize img with attribut sizeHW in propertie
|
||||
fs.writeFileSync(`${objectPathname}/${filenameimg}`, imgb64,{encoding:"base64"});
|
||||
fs.writeFileSync(`${objectPathname}/${filenameimg}`, imgb64, {
|
||||
encoding: "base64",
|
||||
});
|
||||
itmtostore[k] = "";
|
||||
}
|
||||
}
|
||||
@ -807,7 +821,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] = [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user