fix: WebAuthn config typo and improve error handling
Deploy Dashboard (Dev) / deploy-dev (push) Successful in 1m41s

- Fix WEBAUTHN_ORIGIN -> WEBAUTHN_ORIGINS env var name
- Add null check for cancelled passkey creation
- Use finally block to ensure loading state is always reset
- Add console.error for better debugging
This commit is contained in:
Gan, Jimmy
2026-03-11 00:53:28 +08:00
parent 75cfafd388
commit 2f8a5d84dc
3 changed files with 43 additions and 11 deletions
@@ -49,6 +49,9 @@
opts.excludeCredentials = opts.excludeCredentials.map(c => ({ ...c, id: base64urlToBuffer(c.id) }));
}
const cred = await navigator.credentials.create({ publicKey: opts });
if (!cred) {
throw new Error("Passkey creation was cancelled");
}
const name = prompt("Name this passkey (e.g. MacBook, iPhone):", "Passkey") || "Passkey";
const body = {
id: cred.id,
@@ -64,9 +67,11 @@
passkeyMsg = "Passkey registered successfully";
await loadPasskeys();
} catch (e) {
console.error("Passkey registration error:", e);
passkeyErr = e.body?.detail || e.message || "Failed to register passkey";
} finally {
passkeyLoading = false;
}
passkeyLoading = false;
}
async function clearPasskeys() {