Commit fe20a393 authored by Bertrand  NÉRON's avatar Bertrand NÉRON
Browse files

add function which

 - allow only admin to create/update document
 - perform some basic checking on structure of newDocument
parent 8d44721b
function(newDoc, oldDoc, userCtx, secObj) {
if(!userCtx || userCtx.roles.indexOf("admin") == -1 ) {
throw({forbidden: "Bad user userCtx.name="+userCtx.name+" , userCtx.roles="+userCtx.roles});
} else {
if (!newDoc.code) throw({forbidden : "Secretion system must have a code"});
if (!newDoc.genes) throw({forbidden : "Secretion system must have a genes"});
if (!newDoc.T3SS_family) throw({forbidden : "Secretion system must have a T3SS_family"});
if (!newDoc.replicon) throw({forbidden : "Secretion system must have a replicon"});
if (!newDoc.replicon.strain) throw({forbidden : "Replicon must have a strain"});
if (!newDoc.replicon.type) throw({forbidden : "Replicon must have a type"});
if (!newDoc.replicon.name) throw({forbidden : "Replicon must have a name"});
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment