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 <m@mk.gg> Co-authored-by: Matt Kane <mkane@cloudflare.com>
This commit is contained in:
5
.changeset/serious-carrots-obey.md
Normal file
5
.changeset/serious-carrots-obey.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@emdash-cms/admin": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes passkey login error handling when no credential is returned from the authenticator
|
||||||
@@ -200,7 +200,10 @@ export function PasskeyLogin({
|
|||||||
const rawCredential = await navigator.credentials.get(credentialOptions);
|
const rawCredential = await navigator.credentials.get(credentialOptions);
|
||||||
|
|
||||||
if (!rawCredential) {
|
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
|
// Step 3: Send credential to server for verification
|
||||||
|
|||||||
Reference in New Issue
Block a user