Is printing an abort/error message as part of a role privilege predicate somehow possible?
privileges: [{
resource: "Collection",
actions: {
write: `(originalDoc, newDoc) => {
if(originalDoc.owner != newDoc.owner) {
abort({
code: "insufficient_permission",
message: "Insufficient Permission. Only the Owner is allowed to change the owner."
})
}
if(originalDoc.access != newDoc.access) {
if(originalDoc.access.any(
(.entity == Query.identity() || .entity == Query.identity().activeOrganization)
&& .action == "UNRESTRICTED"
)
) {
true
} else {
abort({
code: "insufficient_permission",
message: "Insufficient Permission. Only the Owner is allowed to change the owner."
})
}
}
doc.access.any(
(.entity == Query.identity() || .entity == Query.identity().activeOrganization)
&& .action == "WRITE"
)
}
`
}
}