Skip to content

Commit 889dfc0

Browse files
committed
fix(frontend): Add user friendly message when webauthn is cancelled
Signed-off-by: Maciek <tomczukmaciej@gmail.com>
1 parent 70b4a70 commit 889dfc0

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

app/src/lib/webauthn.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,13 @@ export async function beginEmailChangeReauth(): Promise<string> {
298298
return token;
299299
} catch (err: unknown) {
300300
const webauthnErr = err as WebAuthnError;
301+
if (webauthnErr.name === 'NotAllowedError') {
302+
throw new Error('Passkey verification was cancelled or timed out.');
303+
}
301304
if (webauthnErr.response?.data?.error) {
302305
throw new Error(webauthnErr.response.data.error);
303306
}
304-
throw new Error(webauthnErr.message || 'Passkey reauthentication failed');
307+
throw new Error(webauthnErr.message || 'Passkey reauthentication failed.');
305308
}
306309
}
307310

@@ -322,9 +325,12 @@ export async function beginAccountDeletionReauth(): Promise<string> {
322325
return token;
323326
} catch (err: unknown) {
324327
const webauthnErr = err as WebAuthnError;
328+
if (webauthnErr.name === 'NotAllowedError') {
329+
throw new Error('Passkey verification was cancelled or timed out.');
330+
}
325331
if (webauthnErr.response?.data?.error) {
326332
throw new Error(webauthnErr.response.data.error);
327333
}
328-
throw new Error(webauthnErr.message || 'Passkey reauthentication failed');
334+
throw new Error(webauthnErr.message || 'Passkey reauthentication failed.');
329335
}
330336
}

0 commit comments

Comments
 (0)