web: fix app lock verification always succeeds

This commit is contained in:
Abdullah Atta
2024-07-12 14:30:37 +05:00
parent c846f8abc8
commit ff0188f602
2 changed files with 7 additions and 5 deletions

View File

@@ -27,7 +27,8 @@ import {
CredentialType,
CredentialWithSecret,
CredentialWithoutSecret,
useKeyStore
useKeyStore,
wrongCredentialError
} from "../../interfaces/key-store";
import { showToast } from "../../utils/toast";
import { WebAuthn } from "../../utils/webauthn";
@@ -412,7 +413,8 @@ async function authenticateAppLock() {
if (!defaultCredential) {
return verifyAccount();
}
return !!(await verifyCredential(defaultCredential, (c) =>
useKeyStore.getState().verifyCredential(c)
));
return !!(await verifyCredential(defaultCredential, async (c) => {
if (!(await useKeyStore.getState().verifyCredential(c)))
throw new Error(wrongCredentialError(c));
}));
}

View File

@@ -513,7 +513,7 @@ function deserializeCredential(
throw new Error("Credentials are of different types.");
}
function wrongCredentialError(query: CredentialQuery): string {
export function wrongCredentialError(query: CredentialQuery): string {
switch (query.type) {
case "password":
return "Wrong password";