如何在Firebase 3.0中注销用户?

问题描述:

根据文档,我强迫用户签名用方法signOut()退出.

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

这是我尝试过的:

var rootRef = firebase.database().ref();
var loggedInUser = firebase.auth();

1. firebase.signOut(); 
2. loggedInUser.signOut(); 
3. rootRef.signOut();
4. signOut();
5. firebase.auth.signOut();

以上五个中的每一个我得到... is not a function.我知道我对新Firebase的引用没有问题,因为firebase.database().ref();firebase.auth();不会引发错误.我也已经在控制台中迁移了该应用程序.

I get ... is not a function for every one of the five above. I know there is no issue with my reference to the new Firebase, since firebase.database().ref(); and firebase.auth(); does not throw error. I have also migrated the app in the console.

在JavaScript中,您可以使用以下方式注销用户:

In JavaScript you can sign out the user with:

firebase.auth().signOut().then(function() {
  console.log('Signed Out');
}, function(error) {
  console.error('Sign Out Error', error);
});