Have been trying to implement MFA for my users for a while now. The problem seems to be that reCAPTCHA does not fire correctly or renders twice. The funny part: This code used to work, users got SMS to their phones, but does however no longer work and therefore they are locked out of their user.
Any help will be greatly appreciated!
const auth = getAuth();
window.recaptchaVerifier = new RecaptchaVerifier("recaptcha-container", { size: 'invisible' }, auth)
recaptchaVerifier.render().then(widgetId => {
window.recaptchaVerifierId = widgetId;
})
const appVerifier = window.recaptchaVerifier;
// Send verification code.
const phoneAuthProvider = new PhoneAuthProvider(auth);
const multiFactorUser = multiFactor(auth.currentUser);
const multiFactorSession = await multiFactorUser.getSession();
const phoneInfoOptions = {
phoneNumber: phonenumber,
session: multiFactorSession
};
const verificationId = await phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
// Have also tried without line 2,3,4
// Have also tried this (also with size as string)
/*window.recaptchaVerifier = new RecaptchaVerifier("recaptcha-container", {
size: 'invisible',
'callback': 'response'
}, auth)*/
//Im almost certain it has to do with this RecaptchaVerifier part.