title: How do I redirect the user after a successful login on firebase?
body: <p>I just started a new project and I'm working on auth. I am able to login the users using email, google or github. But how do I redirect them to another page on a successful login:
  Here is the code below:</p>
  
  <pre><code>var config = {
  apiKey: "asdfasdfasdf",
  authDomain: "asdfasdfasdf",
  databaseURL: "asdfasdfasdf",
  storageBucket: "asdfasdfasdf",
  };
  firebase.initializeApp(config);
  
  //The stuff
  var logine = document.getElementById("logine");
  var reggy = document.getElementById("reggy");
  var usr = document.getElementById("usr");
  var pwd = document.getElementById("pwd");
  var reset = document.getElementById("forgot");
  var google = document.getElementById("google");
  var logout = document.getElementById("logout");
  var github = document.getElementById("github");
  
  //Login event
  function loginEvent(){
  //Retreive the email and dat pwd
  var email = usr.value;
  var password = pwd.value;
  var auth = firebase.auth();
  //User signs in
  var promise = auth.signInWithEmailAndPassword(email,password).catch(function(error){
  //Handle any errors here
  var errorCode = error.code;
    var errorMessage = error.message;
  
    if (errorCode === 'auth/wrong-password'){
      alert('Get the password right');
    } else {
      alert(errorMessage);
    }
  });
  promise.catch(e =&gt; console.log(e.message));
  if (email.length &lt; 12){
    document.getElementById("bademail").classList.remove("hide");
  
  }
  if(password.length &lt; 6){
    document.getElementById("bademail").classList.remove("hide");
  }
  }
  
  //Register event
  function registerEvent(){
      var email = usr.value;
  var password = pwd.value;
  var auth = firebase.auth();
  
  //User signs in
  
  // TODO: Check for email 
  var promise = auth.createUserWithEmailAndPassword(email, password).catch(function(error){
    //Handle any errors here
    var errorCode = error.code;
    var errorMessage = error.message;
  
    if(errorCode === 'auth/weak-password'){
      alert('All passwords are must be 6 characters or more')
    } else {
      alert(errorMessage);
    }
  
    });
    promise
    .catch(e =&gt; console.log(e.message));
    if (email.length &lt; 12){
    document.getElementById("bademail").classList.remove("hide");
    }
  
    }
  function logoutEvent(){
  firebase.auth().signOut();
  }
  //Signing in with Google
  function googleAuth(){
   //Google Auth
  var provider = new firebase.auth.GoogleAuthProvider();
  firebase.auth().signInWithPopup(provider).then(function(result) {
  // This gives you a Google Access Token. You can use it to access the Google API.
  var token = result.credential.accessToken;
  // The signed-in user info.
  var user = result.user;
  // ...
  }).catch(function(error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  // The email of the user's account used.
  var email = error.email;
  // The firebase.auth.AuthCredential type that was used.
  var credential = error.credential;
  // ...
  });
  }
  //Signing in with github
  function githubAuth(){
  var provider = new firebase.auth.GithubAuthProvider();
  firebase.auth().signInWithPopup(provider).then(function(result) {
  // This gives you a GitHub Access Token. You can use it to access the GitHub API.
  var token = result.credential.accessToken;
  // The signed-in user info.
  var user = result.user;
  // ...
  }).catch(function(error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  // The email of the user's account used.
  var email = error.email;
  // The firebase.auth.AuthCredential type that was used.
  var credential = error.credential;
  // ...
  });
  
  }
  //Password reset email
  function sendPasswordReset() {
    var email = document.getElementById('usr').value;
    // [START sendpasswordemail]
    firebase.auth().sendPasswordResetEmail(email).then(function() {
      // Password Reset Email Sent!
      // [START_EXCLUDE]
      alert('We sent the email so check tu inbox');
      // [END_EXCLUDE]
    }).catch(function(error) {
      // Handle Errors here.
      var errorCode = error.code;
      var errorMessage = error.message;
      // [START_EXCLUDE]
      if (errorCode == 'auth/invalid-email') {
        alert(errorMessage);
      } else if (errorCode == 'auth/user-not-found') {
        alert(errorMessage);
      }
      console.log(error);
      // [END_EXCLUDE]
      });
      // [END sendpasswordemail];
      }
  
    //Realtime listener
    firebase.auth().onAuthStateChanged(firebaseUser =&gt; {
    if(firebaseUser){
    console.log(firebaseUser);
    document.getElementById("logout").classList.remove('hide');
    window.location("index.html");
        }else{
    console.log("GET OUT KID");
    document.getElementById("logout").classList.add('hide');
          reset.addEventListener('click', sendPasswordReset, false);
          google.addEventListener('click', googleAuth, false);
          logine.addEventListener('click', loginEvent, false);
          reggy.addEventListener('click', registerEvent, false);
          logout.addEventListener('click', logoutEvent, false);
          github.addEventListener('click', githubAuth, false);
  }
  });
  </code></pre>