Rough draft to combine user verification required and master password required prompts

This commit is contained in:
gbubemismith 2023-10-10 21:58:27 -04:00
parent ee7844d6b1
commit f72d6f877f
No known key found for this signature in database
1 changed files with 18 additions and 7 deletions

View File

@ -220,9 +220,10 @@ export class Fido2Component implements OnInit, OnDestroy {
async submit() {
const data = this.message$.value;
if (data?.type === "PickCredentialRequest") {
let userVerified = false;
if (data.userVerification) {
userVerified = await this.passwordRepromptService.showPasswordPrompt();
const userVerified = await this.handleUserVerification(data.userVerification);
if (!userVerified) {
return;
}
this.send({
@ -232,8 +233,6 @@ export class Fido2Component implements OnInit, OnDestroy {
userVerified,
});
} else if (data?.type === "ConfirmNewCredentialRequest") {
let userVerified = false;
if (this.cipher.login.fido2Credentials.length > 0) {
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "overwritePasskey" },
@ -246,8 +245,10 @@ export class Fido2Component implements OnInit, OnDestroy {
}
}
if (data.userVerification) {
userVerified = await this.passwordRepromptService.showPasswordPrompt();
const userVerified = await this.handleUserVerification(data.userVerification);
if (!userVerified) {
return;
}
this.send({
@ -404,6 +405,16 @@ export class Fido2Component implements OnInit, OnDestroy {
this.destroy$.complete();
}
private async handleUserVerification(userVerification: boolean): Promise<boolean> {
const masterPasswordRempromptRequired = this.cipher && this.cipher.reprompt !== 0;
if (!masterPasswordRempromptRequired && !userVerification) {
return true;
}
return await this.passwordRepromptService.showPasswordPrompt();
}
private send(msg: BrowserFido2Message) {
BrowserFido2UserInterfaceSession.sendMessage({
sessionId: this.sessionId,