2021-08-26 10:04:29 +02:00
|
|
|
import { Directive } from "@angular/core";
|
|
|
|
|
2022-06-14 17:10:53 +02:00
|
|
|
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
|
|
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|
|
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
2022-02-22 15:39:11 +01:00
|
|
|
|
2021-08-26 10:04:29 +02:00
|
|
|
import { ModalRef } from "./modal/modal.ref";
|
|
|
|
|
2022-04-12 03:48:33 +02:00
|
|
|
/**
|
|
|
|
* Used to verify the user's Master Password for the "Master Password Re-prompt" feature only.
|
|
|
|
* See UserVerificationComponent for any other situation where you need to verify the user's identity.
|
|
|
|
*/
|
2021-08-26 10:04:29 +02:00
|
|
|
@Directive()
|
|
|
|
export class PasswordRepromptComponent {
|
|
|
|
showPassword = false;
|
|
|
|
masterPassword = "";
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private modalRef: ModalRef,
|
|
|
|
private cryptoService: CryptoService,
|
|
|
|
private platformUtilsService: PlatformUtilsService,
|
|
|
|
private i18nService: I18nService
|
2021-12-16 13:36:21 +01:00
|
|
|
) {}
|
2021-08-26 10:04:29 +02:00
|
|
|
|
|
|
|
togglePassword() {
|
|
|
|
this.showPassword = !this.showPassword;
|
|
|
|
}
|
|
|
|
|
|
|
|
async submit() {
|
|
|
|
if (!(await this.cryptoService.compareAndUpdateKeyHash(this.masterPassword, null))) {
|
|
|
|
this.platformUtilsService.showToast(
|
2021-12-16 13:36:21 +01:00
|
|
|
"error",
|
2021-08-26 10:04:29 +02:00
|
|
|
this.i18nService.t("errorOccurred"),
|
|
|
|
this.i18nService.t("invalidMasterPassword")
|
|
|
|
);
|
2021-12-16 13:36:21 +01:00
|
|
|
return;
|
2021-08-26 10:04:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.modalRef.close(true);
|
|
|
|
}
|
|
|
|
}
|