How do I sign out users in Firebase 3.0?

后端 未结 5 1604
甜味超标
甜味超标 2021-02-03 19:09

According to documentation, I force a user to sign out with the method signOut().

This is what I have tried:

var rootRef = firebase.database         


        
5条回答
  •  野的像风
    2021-02-03 19:57

    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);
    });
    

提交回复
热议问题