function toggleSignIn() {
    if (firebase.auth().currentUser) {
      // [START signout]
      firebase.auth().signOut();
      // [END signout]
    } else {
      var email = document.getElementById('email').value;
      var password = document.getElementById('password').value;
      //var displayName = document.getElementById('displayName').value;

      if (email.length < 4) {
        alert('Please enter an email address.');
        return;
      }
      if (password.length < 4) {
        alert('Please enter a password.');
        return;
      }

      // Sign in with email and pass.
      // [START authwithemail]
      firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
        // Handle Errors here.
        var errorCode = error.code;
        var errorMessage = error.message;
        // [START_EXCLUDE]
        if (errorCode === 'auth/wrong-password') {
          alert('Wrong password.');
        } else {
          alert(errorMessage);
        }
        console.log(error);
        document.getElementById('quickstart-sign-in').disabled = false;
        // [END_EXCLUDE]
      });
      // [END authwithemail]
    }

    // Listening for auth state changes.
    // [START authstatelistener]
    firebase.auth().onAuthStateChanged(function(user) {

      // [START_EXCLUDE silent]
      //document.getElementById('quickstart-verify-email').disabled = true;
      //$('#profile').show()
      //$('#profile').append("<p>Hello Tarfah!</p>");
      // [END_EXCLUDE]
      if (user) {
        // User is signed in.
        //var displayName = user.displayName;
        var email = user.email;
        var emailVerified = user.emailVerified;
        // var photoURL = user.photoURL;
        // var isAnonymous = user.isAnonymous;
        // var uid = user.uid;
        // var providerData = user.providerData;
        // [START_EXCLUDE]

        //writeUserData(user.uid, document.getElementById('displayName').value, user.email);

        //document.getElementById('quickstart-sign-in-status').textContent = 'Signed in';
        document.getElementById('quickstart-sign-in').textContent = 'Sign out';
        //show the sign out button
        $('#acc').show();
        $('#signout').show();
        //console.log(JSON.stringify(user, null, '  '));
        //document.getElementById('quickstart-account-details').textContent = JSON.stringify(user, null, '  ');
        if (!emailVerified) {
          //document.getElementById('quickstart-verify-email').disabled = false;
        }

        firebase.database().ref('/users/' + user.uid).once('value').then(function(snapshot) {
          var displayName = snapshot.val().name;
          console.log("NAME: ", displayName);
          //currUser = displayName;
          $("#SignupLogin").html(displayName);
          window.location.href='api-integration.html';
        });

        // [END_EXCLUDE]
      } else {
        // User is signed out.
        // [START_EXCLUDE]
        //document.getElementById('quickstart-sign-in-status').textContent = 'Signed out';
        document.getElementById('quickstart-sign-in').textContent = 'Sign in';
        //document.getElementById('quickstart-account-details').textContent = 'null';
        // [END_EXCLUDE]
        $("#SignupLogin").html('Sign in');
      }
      // [START_EXCLUDE silent]
      document.getElementById('quickstart-sign-in').disabled = false;
      // [END_EXCLUDE]
    });

    document.getElementById('quickstart-sign-in').disabled = true;

  }
//Handles the sign in button press.
Handles the sign in button press.
Handles the sign in button press .
function toggleSignIn() {
    if (firebase.auth().currentUser) {
      firebase.auth().signOut();
    } else {
      var email = document.getElementById('email').value;
      var password = document.getElementById('password').value;
      if (email.length < 4) {
        alert('Please enter an email address.');
        return;
      }
      if (password.length < 4) {
        alert('Please enter a password.');
        return;
      }
      firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
        var errorCode = error.code;
        var errorMessage = error.message;
        if (errorCode === 'auth/wrong-password') {
          alert('Wrong password.');
        } else {
          alert(errorMessage);
        }
        console.log(error);
        document.getElementById('quickstart-sign-in').disabled = false;
      });
    }
    firebase.auth().onAuthStateChanged(function(user) {
      if (user) {
        var email = user.email;
        var emailVerified = user.emailVerified;
        document.getElementById('quickstart-sign-in').textContent = 'Sign out';
        $('#acc').show();
        $('#signout').show();
        if (!emailVerified) {
        }
        firebase.database().ref('/users/' + user.uid).once('value').then(function(snapshot) {
          var displayName = snapshot.val().name;
          console.log("NAME: ", displayName);
          $("#SignupLogin").html(displayName);
          window.location.href='api-integration.html';
        });
      } else {
        document.getElementById('quickstart-sign-in').textContent = 'Sign in';
        $("#SignupLogin").html('Sign in');
      }
      document.getElementById('quickstart-sign-in').disabled = false;
    });
    document.getElementById('quickstart-sign-in').disabled = true;
  }
function toggleSignIn ( ) { if ( firebase . auth ( ) . currentUser ) { firebase . auth ( ) . signOut ( ) ; } else { var email = document . getElementById ( 'email' ) . value ; var password = document . getElementById ( 'password' ) . value ; if ( email . length < 4 ) { alert ( 'Please enter an email address.' ) ; return ; } if ( password . length < 4 ) { alert ( 'Please enter a password.' ) ; return ; } firebase . auth ( ) . signInWithEmailAndPassword ( email , password ) . catch ( function ( error ) { var errorCode = error . code ; var errorMessage = error . message ; if ( errorCode === 'auth/wrong-password' ) { alert ( 'Wrong password.' ) ; } else { alert ( errorMessage ) ; } console . log ( error ) ; document . getElementById ( 'quickstart-sign-in' ) . disabled = false ; } ) ; } firebase . auth ( ) . onAuthStateChanged ( function ( user ) { if ( user ) { var email = user . email ; var emailVerified = user . emailVerified ; document . getElementById ( 'quickstart-sign-in' ) . textContent = 'Sign out' ; $ ( '#acc' ) . show ( ) ; $ ( '#signout' ) . show ( ) ; if ( ! emailVerified ) { } firebase . database ( ) . ref ( '/users/' + user . uid ) . once ( 'value' ) . then ( function ( snapshot ) { var displayName = snapshot . val ( ) . name ; console . log ( "NAME: " , displayName ) ; $ ( "#SignupLogin" ) . html ( displayName ) ; window . location . href = 'api-integration.html' ; } ) ; } else { document . getElementById ( 'quickstart-sign-in' ) . textContent = 'Sign in' ; $ ( "#SignupLogin" ) . html ( 'Sign in' ) ; } document . getElementById ( 'quickstart-sign-in' ) . disabled = false ; } ) ; document . getElementById ( 'quickstart-sign-in' ) . disabled = true ; }
Handles the sign in button press.
Handles the sign in button press .
// [START signout] // [END signout] //var displayName = document.getElementById('displayName').value; // Sign in with email and pass. // [START authwithemail] // Handle Errors here. // [START_EXCLUDE] // [END_EXCLUDE] // [END authwithemail] // Listening for auth state changes. // [START authstatelistener] // [START_EXCLUDE silent] //document.getElementById('quickstart-verify-email').disabled = true; //$('#profile').show() //$('#profile').append("<p>Hello Tarfah!</p>"); // [END_EXCLUDE] // User is signed in. //var displayName = user.displayName; // var photoURL = user.photoURL; // var isAnonymous = user.isAnonymous; // var uid = user.uid; // var providerData = user.providerData; // [START_EXCLUDE] //writeUserData(user.uid, document.getElementById('displayName').value, user.email); //document.getElementById('quickstart-sign-in-status').textContent = 'Signed in'; //show the sign out button //console.log(JSON.stringify(user, null, '  ')); //document.getElementById('quickstart-account-details').textContent = JSON.stringify(user, null, '  '); //document.getElementById('quickstart-verify-email').disabled = false; //currUser = displayName; // [END_EXCLUDE] // User is signed out. // [START_EXCLUDE] //document.getElementById('quickstart-sign-in-status').textContent = 'Signed out'; //document.getElementById('quickstart-account-details').textContent = 'null'; // [END_EXCLUDE] // [START_EXCLUDE silent] // [END_EXCLUDE]