pagans with addprofils

This commit is contained in:
2024-05-30 12:24:46 +02:00
parent 82da00caef
commit d2ed5349fc
2 changed files with 213 additions and 94 deletions

View File

@@ -427,7 +427,7 @@ Odmdb.search = (objectPathname, objsearch, role) => {
role.xprofils = role.xprofils.filter((e) => e !== "owner");
}
objsearch.fields.forEach((f) => {
if (accessright.R.length==0 || accessright.R.includes(f)) {
if (accessright.R.length == 0 || accessright.R.includes(f)) {
ifields[f] = itm[f];
} else {
//ifields[f] = "unauthorized";
@@ -566,7 +566,7 @@ Odmdb.accessright = (apxaccessrights, role) => {
//if (log) console.log(currentmod,"apxaccessrights",apxaccessrights)
//if (log) console.log(currentmod,"role",role)
const accessright = {};
console.log()
console.log();
role.xprofils.forEach((p) => {
if (apxaccessrights[p]) {
Object.keys(apxaccessrights[p]).forEach((act) => {
@@ -649,6 +649,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
},
};
}
const feedbackinfo = {};
const itmold = existid
? fs.readJSONSync(
`${objectPathname}/itm/${itm[getschema.data.schema.apxid]}.json`
@@ -667,7 +668,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
getschema.data.schema.apxaccessrights,
role
);
if (log) console.log(currentmod, "Accessright to: ", accessright);
if (
(crud == "C" && !accessright.C) ||
(crud == "D" && !accessright.D) ||
@@ -696,6 +697,12 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
let itmtostore = itm;
if (crud == "U" && accessright.U.length > 0) {
itmtostore = itmold;
const keynotallow = Object.keys(itm).filter(
(el) => !accessright.U.includes(el)
);
if (keynotallow.length > 0) {
feedbackinfo.keynotallow = keynotallow;
}
accessright.U.forEach((p) => {
itmtostore[p] = itm[p];
});
@@ -736,7 +743,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
status: 200,
ref: "Odmdb",
msg: "cudsuccessfull",
data: {},
data: feedbackinfo,
};
};
/**