1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-28 12:45:45 +01:00
bitwarden-browser/libs/vault/src/services/password-reprompt.service.ts
renovate[bot] 28de9439be
[deps] Autofill: Update prettier to v3 (#7014)
* [deps] Autofill: Update prettier to v3

* prettier formatting updates

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
2023-11-29 16:15:20 -05:00

42 lines
1.2 KiB
TypeScript

import { Injectable } from "@angular/core";
import { lastValueFrom } from "rxjs";
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
import { DialogService } from "@bitwarden/components";
import { PasswordRepromptComponent } from "../components/password-reprompt.component";
/**
* Used to verify the user's Master Password for the "Master Password Re-prompt" feature only.
* See UserVerificationService for any other situation where you need to verify the user's identity.
*/
@Injectable()
export class PasswordRepromptService {
constructor(
private dialogService: DialogService,
private userVerificationService: UserVerificationService,
) {}
protectedFields() {
return ["TOTP", "Password", "H_Field", "Card Number", "Security Code"];
}
async showPasswordPrompt() {
if (!(await this.enabled())) {
return true;
}
const dialog = this.dialogService.open<boolean>(PasswordRepromptComponent, {
ariaModal: true,
});
const result = await lastValueFrom(dialog.closed);
return result === true;
}
async enabled() {
return await this.userVerificationService.hasMasterPasswordAndMasterKeyHash();
}
}