Skip to content

Commit

Permalink
Merge pull request #4179 from alkem-io/server-4178
Browse files Browse the repository at this point in the history
fix deletion + auth propagation for storage aggregator on account
  • Loading branch information
techsmyth committed Jun 29, 2024
2 parents cd5c2f5 + a29ef81 commit 4fdb2d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/domain/space/account/account.service.authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { IVirtualContributor } from '@domain/community/virtual-contributor';
import { VirtualContributorAuthorizationService } from '@domain/community/virtual-contributor/virtual.contributor.service.authorization';
import { ICredentialDefinition } from '@domain/agent/credential/credential.definition.interface';
import { AccountHostService } from '../account.host/account.host.service';
import { StorageAggregatorAuthorizationService } from '@domain/storage/storage-aggregator/storage.aggregator.service.authorization';

@Injectable()
export class AccountAuthorizationService {
Expand All @@ -41,6 +42,7 @@ export class AccountAuthorizationService {
private platformAuthorizationService: PlatformAuthorizationPolicyService,
private spaceAuthorizationService: SpaceAuthorizationService,
private virtualContributorAuthorizationService: VirtualContributorAuthorizationService,
private storageAggregatorAuthorizationService: StorageAggregatorAuthorizationService,
private accountService: AccountService,
private accountHostService: AccountHostService
) {}
Expand All @@ -56,6 +58,7 @@ export class AccountAuthorizationService {
library: true,
defaults: true,
virtualContributors: true,
storageAggregator: true,
},
}
);
Expand All @@ -65,7 +68,8 @@ export class AccountAuthorizationService {
!account.library ||
!account.license ||
!account.defaults ||
!account.virtualContributors
!account.virtualContributors ||
!account.storageAggregator
) {
throw new RelationshipNotFoundException(
`Unable to load Account with entities at start of auth reset: ${account.id} `,
Expand Down Expand Up @@ -109,6 +113,12 @@ export class AccountAuthorizationService {
account.authorization
);

account.storageAggregator =
await this.storageAggregatorAuthorizationService.applyAuthorizationPolicy(
account.storageAggregator,
account.authorization
);

account.defaults.authorization =
this.authorizationPolicyService.inheritParentAuthorization(
account.defaults.authorization,
Expand Down
5 changes: 4 additions & 1 deletion src/domain/space/account/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export class AccountService {
license: true,
defaults: true,
virtualContributors: true,
storageAggregator: true,
},
});

Expand All @@ -257,7 +258,8 @@ export class AccountService {
!account.license ||
!account.defaults ||
!account.library ||
!account.virtualContributors
!account.virtualContributors ||
!account.storageAggregator
) {
throw new RelationshipNotFoundException(
`Unable to load all entities for deletion of account ${account.id} `,
Expand All @@ -276,6 +278,7 @@ export class AccountService {

await this.licenseService.delete(account.license.id);
await this.spaceDefaultsService.deleteSpaceDefaults(account.defaults.id);
await this.storageAggregatorService.delete(account.storageAggregator.id);

// Remove the account host credential
host.agent = await this.agentService.revokeCredential({
Expand Down

0 comments on commit 4fdb2d0

Please sign in to comment.