如何在Firebase 3.0中注销用户?

hel*_*ght 32 javascript firebase firebase-authentication

根据文档,我强制用户注销该方法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();
Run Code Online (Sandbox Code Playgroud)

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

Fra*_*len 81

在JavaScript中,您可以使用以下命令退出用户:

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

  • 我这样做,我的日志"已退出"在控制台中,但我的firebase.auth().onAuthStateChanged()立即在使用:( JS SDK 3.5.2仍然登录的用户返回 (5认同)

Thi*_*yen 6

firebase.auth().signOut()
Run Code Online (Sandbox Code Playgroud)

简直对我有用!