javascript - Auth firebase onAuthStateChange -


when user logs in successfully, redirected main page (which want), keeps refreshing time. idea reason be?

code:

firebaseapp.auth().onauthstatechanged(user => {      if(user){         console.log('user signed in', user);         window.location='/';      }else{         console.log('user not signed in');      } }) 

a guess; because code gets executed again after page loaded , keeps redirecting? if case wrap if or make sure code embedded on login page.

firebaseapp.auth().onauthstatechanged(user => {  if(user){     console.log('user signed in', user);     if(window.location.href != "/"){         window.location='/';     }  }else{     console.log('user not signed in');  }  }) 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -