Skip to content

Commit 1f964cc

Browse files
Add support for showing error indicating passkey is not supported
1 parent 12006e0 commit 1f964cc

File tree

6 files changed

+38
-18
lines changed

6 files changed

+38
-18
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: 18 additions & 10 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/recoverAccountWithToken/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ function PasskeyRecoverAccountWithTokenTheme(props: RecoverAccountWithTokenTheme
187187
case "INVALID_AUTHENTICATOR_ERROR":
188188
setErrorMessageLabel("WEBAUTHN_ACCOUNT_RECOVERY_INVALID_AUTHENTICATOR_ERROR");
189189
break;
190+
case "WEBAUTHN_NOT_SUPPORTED_ERROR":
191+
setErrorMessageLabel("WEBAUTHN_NOT_SUPPORTED_ERROR");
192+
break;
190193
default:
191194
throw new Error("Should never come here");
192195
}

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ 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 response;
44-
}
45-
46-
if (response.status === "FAILED_TO_AUTHENTICATE_USER" || response.status === "INVALID_OPTIONS_ERROR") {
47-
setError("WEBAUTHN_PASSKEY_RECOVERABLE_ERROR");
48-
return response;
41+
switch (response.status) {
42+
case "INVALID_CREDENTIALS_ERROR":
43+
setError("WEBAUTHN_PASSKEY_INVALID_CREDENTIALS_ERROR");
44+
break;
45+
case "FAILED_TO_AUTHENTICATE_USER":
46+
case "INVALID_OPTIONS_ERROR":
47+
setError("WEBAUTHN_PASSKEY_RECOVERABLE_ERROR");
48+
break;
49+
case "WEBAUTHN_NOT_SUPPORTED":
50+
setError("WEBAUTHN_NOT_SUPPORTED_ERROR");
51+
break;
4952
}
5053

5154
return response;

lib/ts/recipe/webauthn/components/themes/signUp/signUpForm.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ export const SignUpForm = (
161161
setErrorLabel("WEBAUTHN_EMAIL_ALREADY_EXISTS_ERROR");
162162
}
163163

164+
if (response.status === "WEBAUTHN_NOT_SUPPORTED") {
165+
setErrorLabel("WEBAUTHN_NOT_SUPPORTED_ERROR");
166+
}
167+
164168
return response;
165169
},
166170
[continueClickResponse, props, userContext]

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@ export const defaultTranslationsWebauthn = {
4747
WEBAUTHN_ACCOUNT_RECOVERY_GENERATED_OPTIONS_NOT_FOUND_ERROR: "Failed to recover account, please try again.",
4848
WEBAUTHN_ACCOUNT_RECOVERY_INVALID_AUTHENTICATOR_ERROR: "Invalid authenticator, please try again.",
4949
WEBAUTHN_EMAIL_ALREADY_EXISTS_ERROR: "Email already exists, please sign in instead.",
50+
WEBAUTHN_NOT_SUPPORTED_ERROR: "Passkey is not supported on your browser, please try with a different browser.",
5051
},
5152
};

0 commit comments

Comments
 (0)