Best way to implement logout in Firebase v3.0.1+? Firebase.unauth is removed after update

Solution 1:

catch error with callback:

firebase.auth().signOut().then(function() {
  // Sign-out successful.
}, function(error) {
  // An error happened.
});

or with .catch as Adam mentioned.

firebase.auth().signOut()
  .then(function() {
    // Sign-out successful.
  })
  .catch(function(error) {
    // An error happened
  });

Or with await and try...catch if inside async function

try {
  await firebase.auth().signOut();
  // signed out
} catch (e){
 // an error
} 

https://firebase.google.com/docs/auth/web/password-auth#next_steps

thanks AndréKool for directions :-)

Solution 2:

Lukas Liesis has the correct firebase signOut() method but to resolve a rejected promise, I used .catch() instead.

firebase.auth().signOut()
  .then(function() {
    // Sign-out successful.
  })
  .catch(function(error) {
    // An error happened
  });

Solution 3:

This statement logouts the user.

    FirebaseAuth.getInstance().signOut();