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 71508f7ae9..a5e5329fce 100644 --- a/apps/web/src/app/auth/settings/account/account.component.html +++ b/apps/web/src/app/auth/settings/account/account.component.html @@ -3,7 +3,7 @@ -
+

{{ "changeEmail" | i18n }}

diff --git a/apps/web/src/app/auth/settings/account/account.component.ts b/apps/web/src/app/auth/settings/account/account.component.ts index dd8dc881f6..51bf427696 100644 --- a/apps/web/src/app/auth/settings/account/account.component.ts +++ b/apps/web/src/app/auth/settings/account/account.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, ViewChild, ViewContainerRef } from "@angular/core"; -import { lastValueFrom, map, Observable, of, switchMap } from "rxjs"; +import { combineLatest, from, lastValueFrom, map, Observable } from "rxjs"; import { ModalService } from "@bitwarden/angular/services/modal.service"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; @@ -21,7 +21,7 @@ export class AccountComponent implements OnInit { @ViewChild("deauthorizeSessionsTemplate", { read: ViewContainerRef, static: true }) deauthModalRef: ViewContainerRef; - showChangeEmail = true; + showChangeEmail$: Observable; showPurgeVault$: Observable; constructor( @@ -33,21 +33,36 @@ export class AccountComponent implements OnInit { ) {} async ngOnInit() { - this.showChangeEmail = await this.userVerificationService.hasMasterPassword(); - this.showPurgeVault$ = this.configService - .getFeatureFlag$(FeatureFlag.AccountDeprovisioning) - .pipe( - switchMap((isAccountDeprovisioningEnabled) => - isAccountDeprovisioningEnabled - ? this.organizationService.organizations$.pipe( - map( - (organizations) => - !organizations.some((o) => o.userIsManagedByOrganization === true), - ), - ) - : of(true), - ), - ); + const isAccountDeprovisioningEnabled$ = this.configService.getFeatureFlag$( + FeatureFlag.AccountDeprovisioning, + ); + + const userIsManagedByOrganization$ = this.organizationService.organizations$.pipe( + map((organizations) => organizations.some((o) => o.userIsManagedByOrganization === true)), + ); + + const hasMasterPassword$ = from(this.userVerificationService.hasMasterPassword()); + + this.showChangeEmail$ = combineLatest([ + hasMasterPassword$, + isAccountDeprovisioningEnabled$, + userIsManagedByOrganization$, + ]).pipe( + map( + ([hasMasterPassword, isAccountDeprovisioningEnabled, userIsManagedByOrganization]) => + hasMasterPassword && (!isAccountDeprovisioningEnabled || !userIsManagedByOrganization), + ), + ); + + this.showPurgeVault$ = combineLatest([ + isAccountDeprovisioningEnabled$, + userIsManagedByOrganization$, + ]).pipe( + map( + ([isAccountDeprovisioningEnabled, userIsManagedByOrganization]) => + !isAccountDeprovisioningEnabled || !userIsManagedByOrganization, + ), + ); } async deauthorizeSessions() {