* Function called when clicking the Login/Logout button.
()
| 64 | * Function called when clicking the Login/Logout button. |
| 65 | */ |
| 66 | function onSignInSubmit() { |
| 67 | if (isPhoneNumberValid()) { |
| 68 | window.signingIn = true; |
| 69 | updateSignInButtonUI(); |
| 70 | const phoneNumber = getPhoneNumberFromUserInput(); |
| 71 | const appVerifier = window.recaptchaVerifier; |
| 72 | signInWithPhoneNumber(auth, phoneNumber, appVerifier!) |
| 73 | .then(function (confirmationResult) { |
| 74 | // SMS sent. Prompt user to type the code from the message, then sign the |
| 75 | // user in with confirmationResult.confirm(code). |
| 76 | window.confirmationResult = confirmationResult; |
| 77 | window.signingIn = false; |
| 78 | updateSignInButtonUI(); |
| 79 | updateVerificationCodeFormUI(); |
| 80 | updateVerifyCodeButtonUI(); |
| 81 | updateSignInFormUI(); |
| 82 | }) |
| 83 | .catch(function (error) { |
| 84 | // Error; SMS not sent |
| 85 | console.error('Error during signInWithPhoneNumber', error); |
| 86 | window.alert( |
| 87 | 'Error during signInWithPhoneNumber:\n\n' + |
| 88 | error.code + |
| 89 | '\n\n' + |
| 90 | error.message, |
| 91 | ); |
| 92 | window.signingIn = false; |
| 93 | updateSignInFormUI(); |
| 94 | updateSignInButtonUI(); |
| 95 | }); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Function called when clicking the "Verify Code" button. |
no test coverage detected