Broaden WebAuthn error handling to show register form

Catch SecurityError and AbortError in addition to NotAllowedError
when login fails — all indicate the user needs to register rather
than showing a cryptic error message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-02-19 01:46:26 +00:00
parent cdd04fe185
commit c0ef77b6b8
1 changed files with 3 additions and 1 deletions

View File

@ -71,7 +71,9 @@ export function AuthButton() {
try { try {
await login(); await login();
} catch (e: any) { } catch (e: any) {
if (e.name === 'NotAllowedError') { // Any WebAuthn error (NotAllowedError, SecurityError, AbortError)
// should show register form — user likely has no passkey yet
if (e.name === 'NotAllowedError' || e.name === 'SecurityError' || e.name === 'AbortError') {
setShowRegister(true); setShowRegister(true);
} else { } else {
setError(e.message || 'Sign in failed'); setError(e.message || 'Sign in failed');