MCPcopy Index your code
hub / github.com/firebase/quickstart-js / onEnrollSendCode

Function onEnrollSendCode

auth/mfa-password.ts:348–376  ·  view source on GitHub ↗

* Handles send code button click for second factor enrollment. * @param {!Event} e The send code for enrollment on click event.

(e: Event)

Source from the content-addressed store, hash-verified

346 * @param {!Event} e The send code for enrollment on click event.
347 */
348async function onEnrollSendCode(e: Event) {
349 e.preventDefault();
350 if (isCaptchaOK() && isPhoneNumberValid() && auth.currentUser) {
351 const phoneNumber = phoneNumberInput.value;
352
353 const provider = new PhoneAuthProvider(auth);
354 multiFactor(auth.currentUser)
355 .getSession()
356 .then(function (multiFactorSession) {
357 const phoneInfoOptions = {
358 phoneNumber: phoneNumber,
359 session: multiFactorSession,
360 };
361 // Send code for enrollment.
362 return provider.verifyPhoneNumber(phoneInfoOptions, recaptchaVerifier!);
363 })
364 .then(
365 function (verificationId) {
366 phoneVerificationId = verificationId;
367 // Update the multi-factor dialog to verify the sent code.
368 updateMfaDialog();
369 },
370 function (error) {
371 updateEnrollSendCodeButtonUI();
372 displayMfaError(error);
373 },
374 );
375 }
376}
377
378/**
379 * Handles verify code button click for second factor enrollment.

Callers

nothing calls this directly

Calls 5

updateMfaDialogFunction · 0.85
displayMfaErrorFunction · 0.85
isCaptchaOKFunction · 0.70
isPhoneNumberValidFunction · 0.70

Tested by

no test coverage detected