modif odmdb accessright
This commit is contained in:
@@ -221,7 +221,7 @@ Odmdb.Schema = (objectPathname, validschema, lg="en") => {
|
||||
status: 404,
|
||||
ref: "Odmdb",
|
||||
msg: "schemanotfound",
|
||||
data: { objectPathname, schema: {} },
|
||||
data: { objectPathname:path.resolve(objectPathname), schema: {} },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -471,6 +471,7 @@ Odmdb.accessright = (apxaccessrights, role) => {
|
||||
|
||||
Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
||||
const getschema = Odmdb.Schema(objectPathname, true);
|
||||
|
||||
if (getschema.status != 200) return getschema;
|
||||
|
||||
if (!itm[getschema.data.schema.apxid]) {
|
||||
@@ -486,7 +487,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
||||
const existid = fs.existsSync(
|
||||
`${objectPathname}/itm/${itm[getschema.data.schema.apxid]}.json`
|
||||
);
|
||||
|
||||
if (log) console.log(currentmod,"Pass schema itm existid = ", existid)
|
||||
/*const pathindex = `${objectPathname}/idx/lst_${getschema.data.schema.apxid}.json`;
|
||||
if (!fs.existsSync(pathindex)) {
|
||||
fs.outputJSONSync(pathindex, []);
|
||||
@@ -538,12 +539,13 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
||||
getschema.data.schema.apxaccessrights,
|
||||
role
|
||||
);
|
||||
if (log) console.log(currentmod,"accessright", accessright);
|
||||
|
||||
if (
|
||||
(crud == "C" && !accessright.C) ||
|
||||
(crud == "D" && !accessright.D) ||
|
||||
(crud == "U" && !accessright.U)
|
||||
) {
|
||||
if (log) console.log(currentmod,"Forbidden accessright:", accessright);
|
||||
return {
|
||||
status: 403,
|
||||
ref: "Odmdb",
|
||||
@@ -578,7 +580,11 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
||||
itmtostore,
|
||||
false
|
||||
);
|
||||
if (chkdata.status != 200) return chkdata;
|
||||
if (chkdata.status != 200) {
|
||||
if (log) console.log(currentmod,"Unconsistency data", chkdata);
|
||||
return chkdata;
|
||||
}
|
||||
if (log) console.log(currentmod,"Data compliance with schema");
|
||||
if (!getschema.data.schema.apxuniquekey)
|
||||
getschema.data.schema.apxuniquekey = [];
|
||||
if (log) console.log(currentmod,`${objectPathname}/itm/${chkdata.data.apxid}.json`);
|
||||
|
Reference in New Issue
Block a user