2016-05-22 53 views
17

根据documentation,我强制用户使用方法signOut()注销。如何注销Firebase 3.0中的用户?

这是我已经试过了,(一次一个,虽然:P):

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();不会引发错误。我也在控制台中迁移了应用程序。

+0

auth()not auth。 –

回答

49

在JavaScript中,你可以退出与用户:

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

太好了,谢谢 – hellogoodnight

+0

我们如何在Java中做到这一点? – Rockstar5645

+2

我这样做,我在控制台中登录'签出',但我的firebase.auth()。onAuthStateChanged()立即返回与用户仍然登录:(使用JS SDK 3.5.2 – horsejockey

1

我不知道如果我理解正确的,但如果你想退出每个用户登录: 那是不可能的,因为代码在客户端上运行,身份验证状态指的是运行它的客户端。

您无法访问连接到Firebase身份验证服务的每个客户端,因为这意味着在服务器端运行代码。

但是,有一个选项可以指定会话的持续时间,即认证部分中的记得参数。

+0

不,目前只是用户在客户端登录 – hellogoodnight

+1

好吧,我的坏,没有完全理解你的问题的第二部分。 – Thib

2
firebase.auth().signOut() 

只是它适合我!