Skip to content

Commit bb17066

Browse files
Add support for showing caution on signup page for email
1 parent 2e35f22 commit bb17066

File tree

3 files changed

+66
-46
lines changed

3 files changed

+66
-46
lines changed

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

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -64,52 +64,55 @@ export const SignUpFormInner = withOverride(
6464
);
6565

6666
return (
67-
<FormBase
68-
clearError={props.clearError}
69-
onFetchError={props.onFetchError}
70-
onError={props.onError}
71-
formFields={[
72-
{
73-
id: "email",
74-
label: "",
75-
labelComponent: (
76-
<div data-supertokens="formLabelWithLinkWrapper">
77-
<Label value={"WEBAUTHN_SIGN_UP_LABEL"} data-supertokens="emailInputLabel" />
78-
<a
79-
onClick={() => props.setActiveScreen(SignUpScreen.RecoverAccount)}
80-
data-supertokens="link linkButton formLabelLinkBtn recoverAccountTrigger">
81-
{t("WEBAUTHN_RECOVER_ACCOUNT_LABEL")}
82-
</a>
83-
</div>
84-
),
85-
optional: false,
86-
autofocus: true,
87-
placeholder: "",
88-
autoComplete: "email",
89-
// We are using the default validator that allows any string
90-
validate: defaultEmailValidator,
91-
},
92-
]}
93-
buttonLabel={"WEBAUTHN_EMAIL_CONTINUE_BUTTON"}
94-
onSuccess={onEmailContinueSuccess}
95-
callAPI={async (formFields) => {
96-
const email = formFields.find((field) => field.id === "email")?.value;
97-
if (email === undefined) {
98-
throw new STGeneralError("GENERAL_ERROR_EMAIL_UNDEFINED");
99-
}
100-
101-
// We do not want the form to make the API call since we have
102-
// an intermediary step here so we will just mock an OK status
103-
// to render the next step.
104-
return {
105-
status: "OK",
106-
email,
107-
};
108-
}}
109-
validateOnBlur={false}
110-
showLabels={true}
111-
footer={props.footer || defaultFooter}
112-
/>
67+
<div data-supertokens="signUpFormInnerContainer">
68+
<div data-supertokens="cautionMessage">{t("WEBAUTHN_SIGN_UP_CAUTION_MESSAGE_LABEL")}</div>
69+
<FormBase
70+
clearError={props.clearError}
71+
onFetchError={props.onFetchError}
72+
onError={props.onError}
73+
formFields={[
74+
{
75+
id: "email",
76+
label: "",
77+
labelComponent: (
78+
<div data-supertokens="formLabelWithLinkWrapper">
79+
<Label value={"WEBAUTHN_SIGN_UP_LABEL"} data-supertokens="emailInputLabel" />
80+
<a
81+
onClick={() => props.setActiveScreen(SignUpScreen.RecoverAccount)}
82+
data-supertokens="link linkButton formLabelLinkBtn recoverAccountTrigger">
83+
{t("WEBAUTHN_RECOVER_ACCOUNT_LABEL")}
84+
</a>
85+
</div>
86+
),
87+
optional: false,
88+
autofocus: true,
89+
placeholder: "",
90+
autoComplete: "email",
91+
// We are using the default validator that allows any string
92+
validate: defaultEmailValidator,
93+
},
94+
]}
95+
buttonLabel={"WEBAUTHN_EMAIL_CONTINUE_BUTTON"}
96+
onSuccess={onEmailContinueSuccess}
97+
callAPI={async (formFields) => {
98+
const email = formFields.find((field) => field.id === "email")?.value;
99+
if (email === undefined) {
100+
throw new STGeneralError("GENERAL_ERROR_EMAIL_UNDEFINED");
101+
}
102+
103+
// We do not want the form to make the API call since we have
104+
// an intermediary step here so we will just mock an OK status
105+
// to render the next step.
106+
return {
107+
status: "OK",
108+
email,
109+
};
110+
}}
111+
validateOnBlur={false}
112+
showLabels={true}
113+
footer={props.footer || defaultFooter}
114+
/>
115+
</div>
113116
);
114117
}
115118
);

lib/ts/recipe/webauthn/components/themes/styles.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@
2525
cursor: pointer;
2626
}
2727

28+
[data-supertokens~="signUpFormInnerContainer"] [data-supertokens~="cautionMessage"] {
29+
padding: 14px;
30+
background: #ff95001a;
31+
color: #7c603e;
32+
font-family: Arial;
33+
font-size: 14px;
34+
font-weight: 400;
35+
line-height: 20px;
36+
text-align: center;
37+
text-underline-position: from-font;
38+
text-decoration-skip-ink: none;
39+
border-radius: 6px;
40+
margin-bottom: 14px;
41+
}
42+
2843
[data-supertokens~="passkeyConfirmationContainer"] [data-supertokens~="passkeyConfirmationEmailContainer"] {
2944
padding-bottom: 5px;
3045
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,7 @@ export const defaultTranslationsWebauthn = {
3838
"The email used is invalid. Please try with a different email ID or reach out to support.",
3939
WEBAUTHN_ACCOUNT_RECOVERY_INVALID_GENERATED_OPTIONS_ERROR: "Failed to recover account, please try again.",
4040
WEBAUTHN_ACCOUNT_RECOVERY_FETCH_ERROR: "Something went wrong, please refresh the page or reach out to support.",
41+
WEBAUTHN_SIGN_UP_CAUTION_MESSAGE_LABEL:
42+
"Make sure your email is correct—we’ll use it to help you recover your account.",
4143
},
4244
};

0 commit comments

Comments
 (0)