* Handles verify code button click for second factor enrollment. * @param {!Event} e The verify code for enrollment on click event.
(e: Event)
| 380 | * @param {!Event} e The verify code for enrollment on click event. |
| 381 | */ |
| 382 | function onEnrollVerifyCode(e: Event) { |
| 383 | e.preventDefault(); |
| 384 | if (auth.currentUser && phoneVerificationId) { |
| 385 | const enrolVerificationCodeInput = document.getElementById( |
| 386 | 'enroll-verification-code', |
| 387 | )! as HTMLInputElement; |
| 388 | const code = enrolVerificationCodeInput.value; |
| 389 | const credential = PhoneAuthProvider.credential(phoneVerificationId, code); |
| 390 | const multiFactorAssertion = |
| 391 | PhoneMultiFactorGenerator.assertion(credential); |
| 392 | const enrollDisplayNameInput = document.getElementById( |
| 393 | 'enroll-display-name', |
| 394 | )! as HTMLInputElement; |
| 395 | const displayName = enrollDisplayNameInput.value || undefined; |
| 396 | // Enroll the phone second factor. |
| 397 | multiFactor(auth.currentUser) |
| 398 | .enroll(multiFactorAssertion, displayName) |
| 399 | .then(function () { |
| 400 | showAccountDetails(auth.currentUser!); |
| 401 | const enrolledFactors = multiFactor(auth.currentUser!).enrolledFactors; |
| 402 | showEnrolledFactors(enrolledFactors); |
| 403 | clearMfaDialog(); |
| 404 | alertMessage('Second factor enrolled!'); |
| 405 | }) |
| 406 | .catch(displayMfaError); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | /** |
| 411 | * Handles send code button click for second factor sign-in. |
nothing calls this directly
no test coverage detected