* Handle the sign in button press.
()
| 33 | * Handle the sign in button press. |
| 34 | */ |
| 35 | function toggleSignIn() { |
| 36 | if (auth.currentUser) { |
| 37 | signOut(auth); |
| 38 | } else { |
| 39 | const token = tokenTextArea.value; |
| 40 | if (token.length < 10) { |
| 41 | alert('Please enter a token in the text area'); |
| 42 | return; |
| 43 | } |
| 44 | // Sign in with custom token generated following previous instructions. |
| 45 | signInWithCustomToken(auth, token).catch(function (error) { |
| 46 | // Handle Errors here. |
| 47 | const errorCode = error.code; |
| 48 | const errorMessage = error.message; |
| 49 | if (errorCode === 'auth/invalid-custom-token') { |
| 50 | alert('The token you provided is not valid.'); |
| 51 | } else { |
| 52 | console.error(error); |
| 53 | } |
| 54 | }); |
| 55 | } |
| 56 | signInButton.disabled = true; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * initApp handles setting up UI event listeners and registering Firebase auth listeners: |
nothing calls this directly
no outgoing calls
no test coverage detected