firebase/quickstart-js

The "Send Code" button for MFA is never enabled even after entering valid phone number and successful recaptcha

faridghar opened this issue · 1 comments

I'm trying to run the the MFA authentication example on Firebase Hosting. After signing up a user and verifying the email, when I click the "Enroll" button and enter a valid phone number (+971XXXXXXX) and successfully do the recaptcha (I see a green check mark), the "Send Code" button remains disabled. Upon debugging, it seems the issue is is in line 396 of the "mfa-password.js" file because the grecpatcha variable is undefined whereas the recaptchaWidgetId variable is not null. So the if condition fails and the function returns false. If I modify the isCaptchaOK() function to simply return true (hardcoded), then the button becomes enabled and I'm able to successfully receive a verification code on my phone.

I'm not a recpatch expert but it doesn't seem like there's anywhere in the mfa-password.js where the grecpatch variable is being initialized. Am I missing something or is this variable somehow initialized by the recaptcha library? If so, why isn't it working in my case?

Based on this, I used window.grecaptcha in the isCaptchaOK() function and it works now. Not sure if I did something wrong or if this code needs to be changed.