diff --git a/sci-log-db/src/mixins/basesnippet.repository-mixin.ts b/sci-log-db/src/mixins/basesnippet.repository-mixin.ts index 06bbd417..c3f087d1 100644 --- a/sci-log-db/src/mixins/basesnippet.repository-mixin.ts +++ b/sci-log-db/src/mixins/basesnippet.repository-mixin.ts @@ -146,7 +146,7 @@ function UpdateAndDeleteRepositoryMixin< acl => basesnippet[acl as keyof typeof basesnippet], ) ) - await self['aclDefaultOnCreation'](merge); + await self['aclDefaultOnCreation'](merge, false); return this.getChanged(merge, snippet); } diff --git a/sci-log-db/src/repositories/autoadd.repository.base.ts b/sci-log-db/src/repositories/autoadd.repository.base.ts index 969fb683..9789e3ff 100644 --- a/sci-log-db/src/repositories/autoadd.repository.base.ts +++ b/sci-log-db/src/repositories/autoadd.repository.base.ts @@ -85,6 +85,7 @@ export class AutoAddRepository< ownerGroup?: string; accessGroups?: string[]; }, + isNewInstance = true, ) { const parent = await this.getParent(data); const acls = [...this.acls]; @@ -107,7 +108,13 @@ export class AutoAddRepository< await this.addToACLIfNotEmpty( acls, data, - _.partial(this.defaultAllButLocationLogbookACL.bind(this), parent), + _.partial( + this.defaultAllButLocationLogbookACL.bind(this), + parent, + _, + _, + isNewInstance, + ), ); delete data.ownerGroup; delete data.accessGroups; @@ -176,12 +183,18 @@ export class AutoAddRepository< private defaultAllButLocationLogbookACL( parent: Basesnippet, aclType: string, - data: {accessGroups?: string[]}, + data: { + accessGroups?: string[]; + createdBy?: string[]; + }, + isNewInstance = true, ) { if (aclType === 'shareACL') return arrayOfUniqueFrom(parent.shareACL, parent.readACL); if (aclType === 'readACL') return arrayOfUniqueFrom(parent.readACL, data.accessGroups); + if (aclType === 'updateACL' && isNewInstance) + return arrayOfUniqueFrom(parent.updateACL, data.createdBy); return parent[aclType as keyof Basesnippet]; }