fix(angular): ensure reCAPTCHA verifier instance consistency in phone authentication #1325
+246
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Similar to #1321
Problem
Phone authentication failed with auth/internal-error because injectRecaptchaVerifier could return different RecaptchaVerifier instances for the same element. Using a different instance than the one rendered caused Firebase's _reset() to fail.
Solution
Cache the rendered verifier instance and always return the same instance for the same element. Prevent duplicate renders and add an SSR guard. Wait for render completion before calling verifyPhoneNumber.