在我的Angular2应用程序中,我使用以下内容注销并重定向回登录。它有效,但我在控制台中遇到了那个可怕的错误。
我有一个工具栏作为标注所在的标题。在正文中我有一个订阅的组件。但是,当我从标题中注销时,不会调用ngOnDestroy。我假设在sigout之前我必须找到加载ccompenent时,杀死组件,然后注销。
那么如何找到当前的主管,杀死它以便触发onDestroy,然后注销?我再次假设这是正在发生的事情。
ngOnDestroy() {
if(this.af_sub){
console.log('killing home')
this.af_sub.unsubscribe();
}
}
ngOnInit() {
this.af.auth.subscribe(user => {
if (user) {
this.user = user.auth.providerData[0];
//console.log(user.auth);
}
else {
this.user = {};
this.router.navigate(['/login']);
}
});
}
logout() {
if (this.user){
this.af.auth.logout();
} else {
//console.log('already logged out');
}
} //end
注销
FIREBASE WARNING: Exception was thrown by user callback. Error: permission_denied at /accounts/DKesxlT2mkUwwJGCaHBTkPHuDwl2/slugs: Client doesn't have permission to access the desired data.
at G (http://localhost:4200/vendor.bundle.js:111598:36) [<root>]
at Object.G (http://localhost:4200/vendor.bundle.js:111602:86) [<root>]
at $g (http://localhost:4200/vendor.bundle.js:111586:98) [<root>]
at Pg.g.wd (http://localhost:4200/vendor.bundle.js:111579:310) [<root>]
at Ce.wd (http://localhost:4200/vendor.bundle.js:111481:364) [<root>]
at cd.Xf (http://localhost:4200/vendor.bundle.js:111479:281) [<root>]
at fd (http://localhost:4200/vendor.bundle.js:111435:464) [<root>]
at WebSocket.Ia.onmessage (http://localhost:4200/vendor.bundle.js:111434:245) [<root>]
at WebSocket.wrapFn [as _onmessage] (http://localhost:4200/vendor.bundle.js:129332:29) [<root>]
at Zone.runTask (http://localhost:4200/vendor.bundle.js:128594:47) [<root> => <root>]
at WebSocket.ZoneTask.invoke (http://localhost:4200/vendor.bundle.js:128788:33) [<root>]
O @ database.js:54
(anonymous) @ database.js:61
ZoneDelegate.invokeTask @ zone.js:275
Zone.runTask @ zone.js:151
ZoneTask.invoke @ zone.js:345
data.args.(anonymous function) @ zone.js:1224
zone.js:682 Uncaught Error: permission_denied at /accounts/DKesxlT2mkUwwJGCaHBTkPHuDwl2/slugs: Client doesn't have permission to access the desired data.
at G (database.js:230) [<root>]
at Object.G (database.js:234) [<root>]
at $g (database.js:218) [<root>]
at Pg.g.wd (database.js:211) [<root>]
at Ce.wd (database.js:113) [<root>]
at cd.Xf (database.js:111) [<root>]
at fd (database.js:67) [<root>]
at WebSocket.Ia.onmessage (database.js:66) [<root>]
at WebSocket.wrapFn [as _onmessage] (zone.js:889) [<root>]
at Zone.runTask (zone.js:151) [<root> => <root>]
at WebSocket.ZoneTask.invoke (zone.js:345) [<root>]
ZoneAwareError @ zone.js:682
G @ database.js:230
(anonymous) @ database.js:234
$g @ database.js:218
g.wd @ database.js:211
Ce.wd @ database.js:113
(anonymous) @ database.js:111
fd @ database.js:67
Ia.onmessage @ database.js:66
wrapFn @ zone.js:889
ZoneDelegate.invokeTask @ zone.js:275
Zone.runTask @ zone.js:151
ZoneTask.invoke @ zone.js:345