From d2aee8f82c5bc1c1d42ad3a4f4d192f910309629 Mon Sep 17 00:00:00 2001 From: Neil Smyth Date: Fri, 20 Sep 2024 12:13:03 +0200 Subject: [PATCH] also do auth reset after revoking a license plan --- .../admin.licensing.resolver.mutations.ts | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/platform/admin/licensing/admin.licensing.resolver.mutations.ts b/src/platform/admin/licensing/admin.licensing.resolver.mutations.ts index 99f3d94eed..cadd9c5489 100644 --- a/src/platform/admin/licensing/admin.licensing.resolver.mutations.ts +++ b/src/platform/admin/licensing/admin.licensing.resolver.mutations.ts @@ -91,16 +91,16 @@ export class AdminLicensingResolverMutations { `assign licensePlan (${planData.licensePlanID}) on account (${planData.spaceID})` ); - const account = await this.adminLicensingService.assignLicensePlanToSpace( + const space = await this.adminLicensingService.assignLicensePlanToSpace( planData, licensing.id ); // Need to trigger an authorization reset as some license credentials are used in auth policy e.g. VCs feature flag const updatedAuthorizations = - await this.spaceAuthorizationService.applyAuthorizationPolicy(account); + await this.spaceAuthorizationService.applyAuthorizationPolicy(space); await this.authorizationPolicyService.saveAll(updatedAuthorizations); - return account; + return space; } @UseGuards(GraphqlGuard) @@ -128,10 +128,16 @@ export class AdminLicensingResolverMutations { `revoke licensePlan (${planData.licensePlanID}) on account (${planData.accountID})` ); - return await this.adminLicensingService.revokeLicensePlanFromAccount( - planData, - licensing.id - ); + const account = + await this.adminLicensingService.revokeLicensePlanFromAccount( + planData, + licensing.id + ); + // Need to trigger an authorization reset as some license credentials are used in auth policy e.g. VCs feature flag + const updatedAuthorizations = + await this.accountAuthorizationService.applyAuthorizationPolicy(account); + await this.authorizationPolicyService.saveAll(updatedAuthorizations); + return account; } @UseGuards(GraphqlGuard) @@ -159,9 +165,13 @@ export class AdminLicensingResolverMutations { `revoke licensePlan (${planData.licensePlanID}) on account (${planData.spaceID})` ); - return await this.adminLicensingService.revokeLicensePlanFromSpace( + const space = await this.adminLicensingService.revokeLicensePlanFromSpace( planData, licensing.id ); + const updatedAuthorizations = + await this.spaceAuthorizationService.applyAuthorizationPolicy(space); + await this.authorizationPolicyService.saveAll(updatedAuthorizations); + return space; } }