Skip to content

Commit

Permalink
Rough draft to combine user verification required and master password…
Browse files Browse the repository at this point in the history
… required prompts
  • Loading branch information
gbubemismith committed Oct 11, 2023
1 parent ee7844d commit f72d6f8
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions apps/browser/src/vault/popup/components/fido2/fido2.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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" },
Expand All @@ -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({
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f72d6f8

Please sign in to comment.