Skip to content

Commit d51fd35

Browse files
Add support for recover account button in sign up for webauthn
1 parent d9f77f7 commit d51fd35

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
import STGeneralError from "supertokens-web-js/utils/error";
1717

1818
import { withOverride } from "../../../../../components/componentOverride/withOverride";
19-
// import { useUserContext } from "../../../../../usercontext";
19+
import { useTranslation } from "../../../../../translation/translationContext";
20+
import { Label } from "../../../../emailpassword/components/library";
2021
import FormBase from "../../../../emailpassword/components/library/formBase";
21-
import { defaultValidate } from "../../../../emailpassword/validators";
22+
import { defaultEmailValidator } from "../../../../emailpassword/validators";
2223

2324
import type { SignUpFormProps } from "../../../types";
2425

@@ -29,7 +30,7 @@ export const SignUpForm = withOverride(
2930
footer?: JSX.Element;
3031
}
3132
): JSX.Element {
32-
// const userContext = useUserContext();
33+
const t = useTranslation();
3334

3435
return (
3536
<FormBase
@@ -39,13 +40,23 @@ export const SignUpForm = withOverride(
3940
formFields={[
4041
{
4142
id: "email",
42-
label: "WEBAUTHN_SIGN_UP_LABEL",
43+
label: "",
44+
labelComponent: (
45+
<div data-supertokens="formLabelWithLinkWrapper">
46+
<Label value={"WEBAUTHN_SIGN_UP_LABEL"} data-supertokens="emailInputLabel" />
47+
<a
48+
onClick={() => alert("That is not defined yet!")}
49+
data-supertokens="link linkButton formLabelLinkBtn recoverAccountTrigger">
50+
{t("WEBAUTHN_RECOVER_ACCOUNT_LABEL")}
51+
</a>
52+
</div>
53+
),
4354
optional: false,
4455
autofocus: true,
4556
placeholder: "",
4657
autoComplete: "email",
4758
// We are using the default validator that allows any string
48-
validate: defaultValidate,
59+
validate: defaultEmailValidator,
4960
},
5061
]}
5162
buttonLabel={"WEBAUTHN_EMAIL_CONTINUE_BUTTON"}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const defaultTranslationsWebauthn = {
55
...defaultTranslationsCommon.en,
66
WEBAUTHN_EMAIL_CONTINUE_BUTTON: "Continue",
77
WEBAUTHN_SIGN_UP_LABEL: "Email",
8+
WEBAUTHN_RECOVER_ACCOUNT_LABEL: "Recover Account",
89
// WEBAUTHN_CONTINUE_WITHOUT_PASSKEY_BUTTON: "Continue without passkey",
910
// WEBAUTHN_CREATE_A_PASSKEY_HEADER: "Create a passkey",
1011
// WEBAUTHN_CONTINUE_WITH_EMAIL_SUBTEXT: "Continue with",

0 commit comments

Comments
 (0)