mirror of
https://github.com/bitwarden/clients.git
synced 2026-02-08 01:44:08 +08:00
* Rename service-factory folder * Move cryptographic service factories * Move crypto models * Move crypto services * Move domain base class * Platform code owners * Move desktop log services * Move log files * Establish component library ownership * Move background listeners * Move background background * Move localization to Platform * Move browser alarms to Platform * Move browser state to Platform * Move CLI state to Platform * Move Desktop native concerns to Platform * Move flag and misc to Platform * Lint fixes * Move electron state to platform * Move web state to Platform * Move lib state to Platform * Fix broken tests * Rename interface to idiomatic TS * `npm run prettier` 🤖 * Resolve review feedback * Set platform as owners of web core and shared * Expand moved services * Fix test types --------- Co-authored-by: Hinton <hinton@users.noreply.github.com>
83 lines
2.9 KiB
TypeScript
83 lines
2.9 KiB
TypeScript
import { Directive, OnInit } from "@angular/core";
|
|
import { Router } from "@angular/router";
|
|
|
|
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
|
|
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
|
import { KeyConnectorService } from "@bitwarden/common/auth/abstractions/key-connector.service";
|
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
|
|
|
import { DialogServiceAbstraction, SimpleDialogType } from "../../services/dialog";
|
|
|
|
@Directive()
|
|
export class RemovePasswordComponent implements OnInit {
|
|
actionPromise: Promise<void | boolean>;
|
|
continuing = false;
|
|
leaving = false;
|
|
|
|
loading = true;
|
|
organization: Organization;
|
|
email: string;
|
|
|
|
constructor(
|
|
private router: Router,
|
|
private stateService: StateService,
|
|
private syncService: SyncService,
|
|
private platformUtilsService: PlatformUtilsService,
|
|
private i18nService: I18nService,
|
|
private keyConnectorService: KeyConnectorService,
|
|
private organizationApiService: OrganizationApiServiceAbstraction,
|
|
private dialogService: DialogServiceAbstraction
|
|
) {}
|
|
|
|
async ngOnInit() {
|
|
this.organization = await this.keyConnectorService.getManagingOrganization();
|
|
this.email = await this.stateService.getEmail();
|
|
await this.syncService.fullSync(false);
|
|
this.loading = false;
|
|
}
|
|
|
|
async convert() {
|
|
this.continuing = true;
|
|
this.actionPromise = this.keyConnectorService.migrateUser();
|
|
|
|
try {
|
|
await this.actionPromise;
|
|
this.platformUtilsService.showToast(
|
|
"success",
|
|
null,
|
|
this.i18nService.t("removedMasterPassword")
|
|
);
|
|
await this.keyConnectorService.removeConvertAccountRequired();
|
|
this.router.navigate([""]);
|
|
} catch (e) {
|
|
this.platformUtilsService.showToast("error", this.i18nService.t("errorOccurred"), e.message);
|
|
}
|
|
}
|
|
|
|
async leave() {
|
|
const confirmed = await this.dialogService.openSimpleDialog({
|
|
title: this.organization.name,
|
|
content: { key: "leaveOrganizationConfirmation" },
|
|
type: SimpleDialogType.WARNING,
|
|
});
|
|
|
|
if (!confirmed) {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
this.leaving = true;
|
|
this.actionPromise = this.organizationApiService.leave(this.organization.id);
|
|
await this.actionPromise;
|
|
this.platformUtilsService.showToast("success", null, this.i18nService.t("leftOrganization"));
|
|
await this.keyConnectorService.removeConvertAccountRequired();
|
|
this.router.navigate([""]);
|
|
} catch (e) {
|
|
this.platformUtilsService.showToast("error", this.i18nService.t("errorOccurred"), e);
|
|
}
|
|
}
|
|
}
|