feat: Add default ACL (#8701)
This commit is contained in:
@@ -367,6 +367,25 @@ RestWrite.prototype.setRequiredFieldsIfNeeded = function () {
|
||||
}
|
||||
};
|
||||
|
||||
// add default ACL
|
||||
if (
|
||||
schema?.classLevelPermissions?.ACL &&
|
||||
!this.data.ACL &&
|
||||
JSON.stringify(schema.classLevelPermissions.ACL) !==
|
||||
JSON.stringify({ '*': { read: true, write: true } })
|
||||
) {
|
||||
const acl = deepcopy(schema.classLevelPermissions.ACL);
|
||||
if (acl.currentUser) {
|
||||
if (this.auth.user?.id) {
|
||||
acl[this.auth.user?.id] = deepcopy(acl.currentUser);
|
||||
}
|
||||
delete acl.currentUser;
|
||||
}
|
||||
this.data.ACL = acl;
|
||||
this.storage.fieldsChangedByTrigger = this.storage.fieldsChangedByTrigger || [];
|
||||
this.storage.fieldsChangedByTrigger.push('ACL');
|
||||
}
|
||||
|
||||
// Add default fields
|
||||
if (!this.query) {
|
||||
// allow customizing createdAt and updatedAt when using maintenance key
|
||||
|
||||
Reference in New Issue
Block a user