Indo Entertain Indo Entertain - 4 months ago 24
Javascript Question

back to login page firebaseUI after sign out?

I just finish create sign out button using FirebaseUI, but if I click sign out button, I still on my page, not back to my login page. The idea is, if I click sign out button, user will sign out and back into login page. How I can make it ?



<!DOCTYPE html>
<html>
<head>
<script src="https://www.gstatic.com/firebasejs/4.1.3/firebase.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<h1>You Done</h1>
<h3 id="myemail"></h3>
<button type="button" id="btnout" class="btn btn-action hide">Sign out</button>
<script>
const btnout = document.getElementById('btnout');
const superemail = document.getElementById('myemail');
const config = {
apiKey: "AIzaSyBIi34ndZxxLq2l1gtpzFnAjohPU18pyCk",
authDomain: "skripsi-adeguntoro.firebaseapp.com",
databaseURL: "https://skripsi-adeguntoro.firebaseio.com",
projectId: "skripsi-adeguntoro",
storageBucket: "skripsi-adeguntoro.appspot.com",
messagingSenderId: "181721142188"
};
firebase.initializeApp(config);
firebase.auth().onAuthStateChanged (firebaseUser =>{
if(firebaseUser){
btnout.classList.remove('hide');
console.log(firebaseUser);
superemail.innerHTML = firebaseUser.email;
}else{
console.log('not login');
btnout.classList.add('hide');
}
});
btnout.addEventListener('click', e => {
firebase.auth().signOut();
});
</script>
</body>
</html>




Answer Source

you can use

window.location = "http://my.url.here";
window.location.href = "http://my.url.here";

try this. it will help you