1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-18 07:25:15 +02:00
bitwarden-browser/angular/src/components/password-reprompt.component.ts

38 lines
1019 B
TypeScript
Raw Normal View History

2021-12-16 13:36:21 +01:00
import { Directive } from "@angular/core";
2021-12-16 13:36:21 +01:00
import { CryptoService } from "jslib-common/abstractions/crypto.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
2022-02-22 15:39:11 +01:00
2021-12-16 13:36:21 +01:00
import { ModalRef } from "./modal/modal.ref";
@Directive()
export class PasswordRepromptComponent {
2021-12-16 13:36:21 +01:00
showPassword = false;
masterPassword = "";
2021-12-16 13:36:21 +01:00
constructor(
private modalRef: ModalRef,
private cryptoService: CryptoService,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService
) {}
2021-12-16 13:36:21 +01:00
togglePassword() {
this.showPassword = !this.showPassword;
}
2021-12-16 13:36:21 +01:00
async submit() {
if (!(await this.cryptoService.compareAndUpdateKeyHash(this.masterPassword, null))) {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("invalidMasterPassword")
);
return;
}
2021-12-16 13:36:21 +01:00
this.modalRef.close(true);
}
}