mirror of
https://github.com/bitwarden/browser
synced 2026-01-03 17:13:47 +00:00
* Update AccountService to include a method for setting the managedByOrganizationId * Update AccountComponent to conditionally show the purgeVault button based on a feature flag and if the user is managed by an organization * Add missing method to FakeAccountService * Remove the setAccountManagedByOrganizationId method from the AccountService abstract class. * Refactor AccountComponent to use OrganizationService to check for managing organization * Rename managesActiveUser to userIsManagedByOrganization * Refactor userIsManagedByOrganization property to be non-nullable in organization data and response models * Refactor organization.data.spec.ts to include non-nullable userIsManagedByOrganization property
67 lines
2.5 KiB
TypeScript
67 lines
2.5 KiB
TypeScript
import { Component, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
|
|
import { lastValueFrom, map, Observable, of, switchMap } from "rxjs";
|
|
|
|
import { ModalService } from "@bitwarden/angular/services/modal.service";
|
|
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
|
import { DialogService } from "@bitwarden/components";
|
|
|
|
import { PurgeVaultComponent } from "../../../vault/settings/purge-vault.component";
|
|
|
|
import { DeauthorizeSessionsComponent } from "./deauthorize-sessions.component";
|
|
import { DeleteAccountDialogComponent } from "./delete-account-dialog.component";
|
|
|
|
@Component({
|
|
selector: "app-account",
|
|
templateUrl: "account.component.html",
|
|
})
|
|
export class AccountComponent implements OnInit {
|
|
@ViewChild("deauthorizeSessionsTemplate", { read: ViewContainerRef, static: true })
|
|
deauthModalRef: ViewContainerRef;
|
|
|
|
showChangeEmail = true;
|
|
showPurgeVault$: Observable<boolean>;
|
|
|
|
constructor(
|
|
private modalService: ModalService,
|
|
private dialogService: DialogService,
|
|
private userVerificationService: UserVerificationService,
|
|
private configService: ConfigService,
|
|
private organizationService: OrganizationService,
|
|
) {}
|
|
|
|
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),
|
|
),
|
|
);
|
|
}
|
|
|
|
async deauthorizeSessions() {
|
|
await this.modalService.openViewRef(DeauthorizeSessionsComponent, this.deauthModalRef);
|
|
}
|
|
|
|
purgeVault = async () => {
|
|
const dialogRef = PurgeVaultComponent.open(this.dialogService);
|
|
await lastValueFrom(dialogRef.closed);
|
|
};
|
|
|
|
deleteAccount = async () => {
|
|
const dialogRef = DeleteAccountDialogComponent.open(this.dialogService);
|
|
await lastValueFrom(dialogRef.closed);
|
|
};
|
|
}
|