2022-07-29 21:49:58 +02:00
|
|
|
import { Component } from "@angular/core";
|
|
|
|
import { FormBuilder } from "@angular/forms";
|
|
|
|
|
2023-02-06 22:53:37 +01:00
|
|
|
import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service";
|
2023-11-27 21:59:44 +01:00
|
|
|
import { Verification } from "@bitwarden/common/auth/types/verification";
|
2023-06-06 22:34:53 +02:00
|
|
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
|
|
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
|
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
2022-07-29 21:49:58 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: "app-delete-account",
|
|
|
|
templateUrl: "delete-account.component.html",
|
|
|
|
})
|
|
|
|
export class DeleteAccountComponent {
|
|
|
|
formPromise: Promise<void>;
|
|
|
|
|
|
|
|
deleteForm = this.formBuilder.group({
|
|
|
|
verification: undefined as Verification | undefined,
|
|
|
|
});
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private i18nService: I18nService,
|
|
|
|
private platformUtilsService: PlatformUtilsService,
|
|
|
|
private formBuilder: FormBuilder,
|
2022-10-18 22:02:11 +02:00
|
|
|
private accountApiService: AccountApiService,
|
2022-07-29 21:49:58 +02:00
|
|
|
private logService: LogService,
|
|
|
|
) {}
|
|
|
|
|
|
|
|
get secret() {
|
|
|
|
return this.deleteForm.get("verification")?.value?.secret;
|
|
|
|
}
|
|
|
|
|
|
|
|
async submit() {
|
|
|
|
try {
|
|
|
|
const verification = this.deleteForm.get("verification").value;
|
2022-10-18 22:02:11 +02:00
|
|
|
this.formPromise = this.accountApiService.deleteAccount(verification);
|
2022-07-29 21:49:58 +02:00
|
|
|
await this.formPromise;
|
|
|
|
this.platformUtilsService.showToast(
|
|
|
|
"success",
|
|
|
|
this.i18nService.t("accountDeleted"),
|
|
|
|
this.i18nService.t("accountDeletedDesc"),
|
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
this.logService.error(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|