* Handles the sign in button press.
()
| 44 | * Handles the sign in button press. |
| 45 | */ |
| 46 | function toggleSignIn() { |
| 47 | if (auth.currentUser) { |
| 48 | signOut(auth); |
| 49 | } else { |
| 50 | const email = emailInput.value; |
| 51 | const password = passwordInput.value; |
| 52 | if (email.length < 4) { |
| 53 | alert('Please enter an email address.'); |
| 54 | return; |
| 55 | } |
| 56 | if (password.length < 4) { |
| 57 | alert('Please enter a password.'); |
| 58 | return; |
| 59 | } |
| 60 | // Sign in with email and pass. |
| 61 | signInWithEmailAndPassword(auth, email, password).catch(function (error) { |
| 62 | // Handle Errors here. |
| 63 | const errorCode = error.code; |
| 64 | const errorMessage = error.message; |
| 65 | if (errorCode === 'auth/wrong-password') { |
| 66 | alert('Wrong password.'); |
| 67 | } else { |
| 68 | alert(errorMessage); |
| 69 | } |
| 70 | console.log(error); |
| 71 | signInButton.disabled = false; |
| 72 | }); |
| 73 | } |
| 74 | signInButton.disabled = true; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Handles the sign up button press. |
nothing calls this directly
no outgoing calls
no test coverage detected