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
Post a Comment