From 804e706fdf83f7c7ec7f8b6c641fd5f08b1bf2b9 Mon Sep 17 00:00:00 2001 From: Rui Tome Date: Fri, 4 Oct 2024 15:59:35 +0100 Subject: [PATCH 1/8] Update AccountService to include a method for setting the managedByOrganizationId --- libs/common/src/auth/abstractions/account.service.ts | 10 ++++++++++ libs/common/src/auth/services/account.service.ts | 7 +++++++ libs/common/src/platform/sync/default-sync.service.ts | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/libs/common/src/auth/abstractions/account.service.ts b/libs/common/src/auth/abstractions/account.service.ts index 849abc65f66..a77bbd96803 100644 --- a/libs/common/src/auth/abstractions/account.service.ts +++ b/libs/common/src/auth/abstractions/account.service.ts @@ -10,6 +10,7 @@ export type AccountInfo = { email: string; emailVerified: boolean; name: string | undefined; + managedByOrganizationId?: string | null; }; export function accountInfoEqual(a: AccountInfo, b: AccountInfo) { @@ -68,6 +69,15 @@ export abstract class AccountService { * @param emailVerified */ abstract setAccountEmailVerified(userId: UserId, emailVerified: boolean): Promise; + /** + * updates the `accounts$` observable with the new ID of the organization the account is managed by. + * @param userId + * @param managedByOrganizationId + */ + abstract setAccountManagedByOrganizationId( + userId: UserId, + managedByOrganizationId?: string | null, + ): Promise; /** * Updates the `activeAccount$` observable with the new active account. * @param userId diff --git a/libs/common/src/auth/services/account.service.ts b/libs/common/src/auth/services/account.service.ts index dceec2cbf13..19e37b8f269 100644 --- a/libs/common/src/auth/services/account.service.ts +++ b/libs/common/src/auth/services/account.service.ts @@ -120,6 +120,13 @@ export class AccountServiceImplementation implements InternalAccountService { await this.setAccountInfo(userId, { emailVerified }); } + async setAccountManagedByOrganizationId( + userId: UserId, + managedByOrganizationId?: string | null, + ): Promise { + await this.setAccountInfo(userId, { managedByOrganizationId }); + } + async clean(userId: UserId) { await this.setAccountInfo(userId, LOGGED_OUT_INFO); await this.removeAccountActivity(userId); diff --git a/libs/common/src/platform/sync/default-sync.service.ts b/libs/common/src/platform/sync/default-sync.service.ts index 322687ce6a6..fe85ab42b27 100644 --- a/libs/common/src/platform/sync/default-sync.service.ts +++ b/libs/common/src/platform/sync/default-sync.service.ts @@ -186,6 +186,10 @@ export class DefaultSyncService extends CoreSyncService { await this.avatarService.setSyncAvatarColor(response.id, response.avatarColor); await this.tokenService.setSecurityStamp(response.securityStamp, response.id); await this.accountService.setAccountEmailVerified(response.id, response.emailVerified); + await this.accountService.setAccountManagedByOrganizationId( + response.id, + response.managedByOrganizationId, + ); await this.billingAccountProfileStateService.setHasPremium( response.premiumPersonally, From ebfcf3a9ca8baac923183c4d6702c9195d99a623 Mon Sep 17 00:00:00 2001 From: Rui Tome Date: Fri, 4 Oct 2024 16:00:09 +0100 Subject: [PATCH 2/8] Update AccountComponent to conditionally show the purgeVault button based on a feature flag and if the user is managed by an organization --- .../settings/account/account.component.html | 8 +++++++- .../settings/account/account.component.ts | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/apps/web/src/app/auth/settings/account/account.component.html b/apps/web/src/app/auth/settings/account/account.component.html index c1764693717..71508f7ae97 100644 --- a/apps/web/src/app/auth/settings/account/account.component.html +++ b/apps/web/src/app/auth/settings/account/account.component.html @@ -12,7 +12,13 @@

{{ "changeEmail" | i18n }}

-