From ab21f29f713a5aa4c087c535608e1a2cab2ef9e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fu=20Abaris?= <135986694+doguabaris@users.noreply.github.com> Date: Mon, 6 Apr 2026 22:05:16 +0200 Subject: [PATCH] fix(admin): avoid locally caught exception in PasskeyLogin (#268) * fix(admin): avoid locally caught exception in PasskeyLogin Why: The passkey login flow threw an error when navigator.credentials.get() returned no credential, but that exception was immediately caught by the local catch block in the same function. This triggered a "throw of exception caught locally" warning and made the failure path less direct. What: - Handle the missing credential case inline instead of throwing locally - Preserve the existing error message shown to the user - Keep the onError callback behavior unchanged * Add changeset --------- Co-authored-by: Matt Kane Co-authored-by: Matt Kane --- .changeset/serious-carrots-obey.md | 5 +++++ packages/admin/src/components/auth/PasskeyLogin.tsx | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/serious-carrots-obey.md diff --git a/.changeset/serious-carrots-obey.md b/.changeset/serious-carrots-obey.md new file mode 100644 index 0000000..d33719f --- /dev/null +++ b/.changeset/serious-carrots-obey.md @@ -0,0 +1,5 @@ +--- +"@emdash-cms/admin": patch +--- + +Fixes passkey login error handling when no credential is returned from the authenticator diff --git a/packages/admin/src/components/auth/PasskeyLogin.tsx b/packages/admin/src/components/auth/PasskeyLogin.tsx index a5a5937..424e484 100644 --- a/packages/admin/src/components/auth/PasskeyLogin.tsx +++ b/packages/admin/src/components/auth/PasskeyLogin.tsx @@ -200,7 +200,10 @@ export function PasskeyLogin({ const rawCredential = await navigator.credentials.get(credentialOptions); if (!rawCredential) { - throw new Error("No credential returned from authenticator"); + const message = "No credential returned from authenticator"; + setState({ status: "error", message }); + onError?.(new Error(message)); + return; } // Step 3: Send credential to server for verification