According to documentation, I force a user to sign out with the method signOut()
.
This is what I have tried:
var rootRef = firebase.database
Extending the answer of @Frank van Puffelen, this code works like a charm, but promise rejection handling inside then()
function as a second parameter is a bad practice.
Rather add a .catch(e)
block.
Because, if error happens at signout()
function then would be handled but if error happens at .then()
block then it wont be handled.
Better code would be,
firebase.auth().signOut()
.then(() => {
console.log('Signed Out');
})
.catch(e=>{
console.error('Sign Out Error', e);
});