Skip to content

Commit bad4b14

Browse files
committed
improv: Add the ability to customize the footer for the captcha plugin
1 parent 0e5c82d commit bad4b14

File tree

4 files changed

+56
-31
lines changed

4 files changed

+56
-31
lines changed

lib/ts/recipe/emailpassword/components/themes/resetPasswordUsingToken/resetPasswordEmail.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ import GeneralError from "../../library/generalError";
2525

2626
import type { EnterEmailProps, EnterEmailStatus } from "../../../types";
2727

28-
const EmailPasswordResetPasswordEmail: React.FC<EnterEmailProps> = (props) => {
28+
const EmailPasswordResetPasswordEmail: React.FC<
29+
EnterEmailProps & {
30+
footer?: JSX.Element;
31+
}
32+
> = (props) => {
2933
const t = useTranslation();
3034
const userContext = useUserContext();
3135
const [status, setStatus] = useState<EnterEmailStatus>("READY");
@@ -117,6 +121,7 @@ const EmailPasswordResetPasswordEmail: React.FC<EnterEmailProps> = (props) => {
117121
}}
118122
showLabels={true}
119123
validateOnBlur={true}
124+
footer={props.footer}
120125
/>
121126
</div>
122127
</div>

lib/ts/recipe/emailpassword/components/themes/resetPasswordUsingToken/submitNewPassword.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ import GeneralError from "../../library/generalError";
2929

3030
import type { SubmitNewPasswordProps, SubmitNewPasswordStatus } from "../../../types";
3131

32-
const EmailPasswordSubmitNewPassword: React.FC<SubmitNewPasswordProps> = (props) => {
32+
const EmailPasswordSubmitNewPassword: React.FC<
33+
SubmitNewPasswordProps & {
34+
footer?: JSX.Element;
35+
}
36+
> = (props) => {
3337
const t = useTranslation();
3438
const userContext = useUserContext();
3539
const [status, setStatus] = useState<SubmitNewPasswordStatus>("READY");
@@ -120,6 +124,7 @@ const EmailPasswordSubmitNewPassword: React.FC<SubmitNewPasswordProps> = (props)
120124
};
121125
}}
122126
showLabels={true}
127+
footer={props.footer}
123128
/>
124129
</div>
125130
</div>

lib/ts/recipe/passwordless/components/themes/signInUpEPCombo/emailForm.tsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,24 @@ import type { SignInUpEPComboEmailFormProps } from "../../../types";
3030

3131
export const EPComboEmailForm = withOverride(
3232
"PasswordlessEPComboEmailForm",
33-
function PasswordlessEPComboEmailForm(props: SignInUpEPComboEmailFormProps): JSX.Element {
33+
function PasswordlessEPComboEmailForm(
34+
props: SignInUpEPComboEmailFormProps & {
35+
footer?: JSX.Element;
36+
}
37+
): JSX.Element {
3438
const t = useTranslation();
35-
39+
let footer = props.footer;
40+
if (!footer && props.showContinueWithPasswordlessLink) {
41+
footer = (
42+
<ContinueWithPasswordlessFooter
43+
isPhoneNumber={false}
44+
onContinueWithPasswordlessClick={props.onContinueWithPasswordlessClick}
45+
onError={props.onError}
46+
config={props.config}
47+
validatePhoneNumber={props.validatePhoneNumber}
48+
/>
49+
);
50+
}
3651
const formFields: FormFieldThemeProps[] = [
3752
{
3853
id: "email",
@@ -67,7 +82,8 @@ export const EPComboEmailForm = withOverride(
6782
props.navigate
6883
)
6984
}
70-
data-supertokens="link linkButton formLabelLinkBtn forgotPasswordLink">
85+
data-supertokens="link linkButton formLabelLinkBtn forgotPasswordLink"
86+
>
7187
{t("PWLESS_COMBO_FORGOT_PW_LINK")}
7288
</a>
7389
</div>
@@ -100,17 +116,7 @@ export const EPComboEmailForm = withOverride(
100116
}}
101117
validateOnBlur={false}
102118
showLabels={true}
103-
footer={
104-
props.showContinueWithPasswordlessLink ? (
105-
<ContinueWithPasswordlessFooter
106-
isPhoneNumber={false}
107-
onContinueWithPasswordlessClick={props.onContinueWithPasswordlessClick}
108-
onError={props.onError}
109-
config={props.config}
110-
validatePhoneNumber={props.validatePhoneNumber}
111-
/>
112-
) : undefined
113-
}
119+
footer={footer}
114120
/>
115121
);
116122
}

lib/ts/recipe/passwordless/components/themes/signInUpEPCombo/emailOrPhoneForm.tsx

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ import type { SignInUpEPComboEmailOrPhoneFormProps } from "../../../types";
3434

3535
export const EPComboEmailOrPhoneForm = withOverride(
3636
"PasswordlessEPComboEmailOrPhoneForm",
37-
function PasswordlessEPComboEmailOrPhoneForm(props: SignInUpEPComboEmailOrPhoneFormProps): JSX.Element {
37+
function PasswordlessEPComboEmailOrPhoneForm(
38+
props: SignInUpEPComboEmailOrPhoneFormProps & {
39+
footer?: JSX.Element;
40+
}
41+
): JSX.Element {
3842
const t = useTranslation();
3943

4044
useEffect(() => {
@@ -59,7 +63,8 @@ export const EPComboEmailOrPhoneForm = withOverride(
5963
<Label value={"PWLESS_SIGN_IN_UP_PHONE_LABEL"} />
6064
<a
6165
onClick={() => props.setIsPhoneNumber(false)}
62-
data-supertokens="link linkButton formLabelLinkBtn contactMethodSwitcher">
66+
data-supertokens="link linkButton formLabelLinkBtn contactMethodSwitcher"
67+
>
6368
{t("PWLESS_SIGN_IN_UP_SWITCH_TO_EMAIL")}
6469
</a>
6570
</div>
@@ -82,7 +87,8 @@ export const EPComboEmailOrPhoneForm = withOverride(
8287
<Label value={"PWLESS_SIGN_IN_UP_EMAIL_LABEL"} />
8388
<a
8489
onClick={() => props.setIsPhoneNumber(true)}
85-
data-supertokens="link linkButton formLabelLinkBtn contactMethodSwitcher">
90+
data-supertokens="link linkButton formLabelLinkBtn contactMethodSwitcher"
91+
>
8692
{t("PWLESS_SIGN_IN_UP_SWITCH_TO_PHONE")}
8793
</a>
8894
</div>
@@ -95,6 +101,18 @@ export const EPComboEmailOrPhoneForm = withOverride(
95101
validate: defaultValidate,
96102
},
97103
];
104+
let footer = props.footer;
105+
if (!footer && props.showContinueWithPasswordlessLink) {
106+
footer = (
107+
<ContinueWithPasswordlessFooter
108+
isPhoneNumber={false}
109+
onContinueWithPasswordlessClick={props.onContinueWithPasswordlessClick}
110+
onError={props.onError}
111+
config={props.config}
112+
validatePhoneNumber={props.validatePhoneNumber}
113+
/>
114+
);
115+
}
98116

99117
if (props.showPasswordField) {
100118
formFields.push({
@@ -117,7 +135,8 @@ export const EPComboEmailOrPhoneForm = withOverride(
117135
props.navigate
118136
)
119137
}
120-
data-supertokens="link linkButton formLabelLinkBtn forgotPasswordLink">
138+
data-supertokens="link linkButton formLabelLinkBtn forgotPasswordLink"
139+
>
121140
{t("PWLESS_COMBO_FORGOT_PW_LINK")}
122141
</a>
123142
</div>
@@ -165,17 +184,7 @@ export const EPComboEmailOrPhoneForm = withOverride(
165184
validateOnBlur={false}
166185
showLabels={true}
167186
onSuccess={props.onSuccess}
168-
footer={
169-
props.showContinueWithPasswordlessLink ? (
170-
<ContinueWithPasswordlessFooter
171-
isPhoneNumber={props.isPhoneNumber}
172-
onContinueWithPasswordlessClick={props.onContinueWithPasswordlessClick}
173-
validatePhoneNumber={props.validatePhoneNumber}
174-
onError={props.onError}
175-
config={props.config}
176-
/>
177-
) : undefined
178-
}
187+
footer={footer}
179188
/>
180189
);
181190
}

0 commit comments

Comments
 (0)