MCPcopy Create free account
hub / github.com/firebase/quickstart-js / toggleSignIn

Function toggleSignIn

auth/email-password.ts:46–75  ·  view source on GitHub ↗

* Handles the sign in button press.

()

Source from the content-addressed store, hash-verified

44 * Handles the sign in button press.
45 */
46function 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.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected