Skip to content

Commit e7eedab

Browse files
Add support for showing error on invalid credentials on signin attempt
1 parent 8812532 commit e7eedab

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

lib/build/recipe/webauthn/components/themes/translations.d.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/webauthnprebuiltui.js

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ts/recipe/webauthn/components/themes/signIn/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@ function PasskeySignInTheme(props: SignInThemeProps): JSX.Element {
3838
userContext,
3939
});
4040

41+
if (response.status === "INVALID_CREDENTIALS_ERROR") {
42+
setError("WEBAUTHN_PASSKEY_INVALID_CREDENTIALS_ERROR");
43+
return;
44+
}
45+
4146
if (response.status === "FAILED_TO_AUTHENTICATE_USER") {
42-
setError("Failed to authenticate user");
47+
setError("WEBAUTHN_PASSKEY_RECOVERABLE_ERROR");
4348
return;
4449
}
4550

@@ -93,9 +98,7 @@ function PasskeySignInTheme(props: SignInThemeProps): JSX.Element {
9398
<UserContextWrapper userContext={props.userContext}>
9499
<ThemeBase userStyles={[rootStyle, props.config.recipeRootStyle, activeStyle]}>
95100
<div data-supertokens="passkeySignInContainer">
96-
{error !== "" && error !== null && (
97-
<RecoverableError errorMessageLabel="WEBAUTHN_PASSKEY_RECOVERABLE_ERROR" />
98-
)}
101+
{error !== "" && error !== null && <RecoverableError errorMessageLabel={error} />}
99102
<ContinueWithPasskeyTheme
100103
{...props}
101104
continueWithPasskeyClicked={handleWebauthnSignInClick}

lib/ts/recipe/webauthn/components/themes/translations.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export const defaultTranslationsWebauthn = {
2121
WEBAUTHN_FEATURE_BLOCK_KEEP_ACCOUNT_SAFER_DETAIL: "Passkey offer state of the art phishing resistance.",
2222
WEBAUTHN_PASSKEY_RECOVERABLE_ERROR:
2323
"The request either timed out, was canceled or the device is already registered. Please try again or try using another device.",
24+
WEBAUTHN_PASSKEY_INVALID_CREDENTIALS_ERROR:
25+
"The passkey is invalid, please try again, possibly with a different device.",
2426
WEBAUTHN_ERROR_GO_BACK_BUTTON_LABEL: "Go back",
2527
WEBAUTHN_UNRECOVERABLE_ERROR: "Something went wrong",
2628
WEBAUTHN_UNRECOVERABLE_ERROR_DETAILS: "Something went wrong with your current session. please try again.",

0 commit comments

Comments
 (0)