Skip to content

Commit 781d254

Browse files
author
Chuan Ren
committed
Update email_and_password.ts
1 parent 5452eb6 commit 781d254

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

packages/auth/src/core/strategies/email_and_password.ts

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,26 @@ export async function sendPasswordResetEmail(
108108
actionCodeSettings
109109
);
110110
}
111-
await authentication.sendPasswordResetEmail(authInternal, request).catch(async (error) => {
112-
if (error.code === `auth/${AuthErrorCode.MISSING_RECAPTCHA_TOKEN}`) {
113-
console.log("Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.");
114-
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, RecaptchaActionName.GET_OOB_CODE, true);
115-
if (actionCodeSettings) {
116-
_setActionCodeSettingsOnRequest(authInternal, requestWithRecaptcha, actionCodeSettings);
111+
await authentication
112+
.sendPasswordResetEmail(authInternal, request)
113+
.catch(async error => {
114+
if (error.code === `auth/${AuthErrorCode.MISSING_RECAPTCHA_TOKEN}`) {
115+
console.log(
116+
'Password resets are protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the password reset flow.'
117+
);
118+
const requestWithRecaptcha = await injectRecaptchaFields(
119+
authInternal,
120+
request,
121+
RecaptchaActionName.GET_OOB_CODE,
122+
true
123+
);
124+
if (actionCodeSettings) {
125+
_setActionCodeSettingsOnRequest(
126+
authInternal,
127+
requestWithRecaptcha,
128+
actionCodeSettings
129+
);
130+
}
117131
}
118132
});
119133
}
@@ -274,10 +288,16 @@ export async function createUserWithEmailAndPassword(
274288
);
275289
signUpResponse = signUp(authInternal, requestWithRecaptcha);
276290
} else {
277-
signUpResponse = signUp(authInternal, request).catch(async (error) => {
291+
signUpResponse = signUp(authInternal, request).catch(async error => {
278292
if (error.code === `auth/${AuthErrorCode.MISSING_RECAPTCHA_TOKEN}`) {
279-
console.log("Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.");
280-
const requestWithRecaptcha = await injectRecaptchaFields(authInternal, request, RecaptchaActionName.SIGN_UP_PASSWORD);
293+
console.log(
294+
'Sign-up is protected by reCAPTCHA for this project. Automatically triggering the reCAPTCHA flow and restarting the sign-up flow.'
295+
);
296+
const requestWithRecaptcha = await injectRecaptchaFields(
297+
authInternal,
298+
request,
299+
RecaptchaActionName.SIGN_UP_PASSWORD
300+
);
281301
return signUp(authInternal, requestWithRecaptcha);
282302
} else {
283303
return Promise.reject(error);

0 commit comments

Comments
 (0)