Hug*_*Hou 9 angularjs firebase angularfire firebase-authentication
因此,每当我从Firebase注销时,我都会加入
Error: permission_denied: Client doesn't have permission to access the desired data.
Run Code Online (Sandbox Code Playgroud)
我理解这是因为登录会话终止,我的一些对象无法再访问firebase数据.但是如何在注销前断开此对象?
对于我的Ionic View中的注销按钮,它只需调用firebase服务:
function logout() {
auth.$unauth();
getCurrentUser();
};
function getCurrentUser() {
var authData = auth.$getAuth();
if (authData) {
$rootScope.userId = authData.uid;
$rootScope.currentUser = $firebaseObject(authRef.child("users").child(authData.uid));
return $rootScope.currentUser;
} else {
console.log("User is not login!");
$rootScope.userId = null;
$location.path("/auth/signin");
if ($rootScope.currentUser) {
$rootScope.currentUser.$destroy();
}
}
};
Run Code Online (Sandbox Code Playgroud)
所以我在那里销毁$ rootScope.currentUser.我为配置文件页面使用相同的getCurrentUser.因此错误没有以这种方式出现.但是在其他视图中,我有另一个$ firebaseArray,还有另一个Ref.on("child_added",函数(snap)与$ firebaseObject相同.当我查看配置文件页面时,此页面至少有3个firebase连接,当我退出时,我有3个permission_denied错误(注销按钮在用户个人资料页面上).
我的问题是,在注销之前如何断开此firebase连接?有没有办法断开所有firebase连接 - 无论是AngularFire还是常规的Firebase?所以我可以注销而不用担心哪个firebase连接没有关闭呢?此外,由于Logout按钮位于Profile范围内,而其他连接位于不同的范围内,因此我不知道如何关闭甚至在配置文件范围内的连接...
小智 0
好吧,我猜你有一个注销按钮。所以在你的函数 logout() 中,你首先 $destroy 数据对象,以某种方式等待(这是我试图找出的最佳实践),然后 authref.unauth(); 我会说
| 归档时间: |
|
| 查看次数: |
2372 次 |
| 最近记录: |