我正在使用Angular2,AngularFire2和Firebase编写一个Web应用程序。
我正在尝试在应用中实现注销功能,但我在使用该功能时遇到错误(如下所示)。
这是我的退出代码
this.dbSubscription = this.userObservable.subscribe();
this.userSubscription = this.af.auth.subscribe();
logout(){
this.dbSubscription.unsubscribe();
this.userSubscription .unsubscribe();
this.af.auth.logout();
}
我无法弄清楚导致此错误的原因。我将不胜感激。
uid是userId我来自firebase
错误讯息:
TypeError: Cannot read property 'uid' of null
at SafeSubscriber._next (database.service.ts:12)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:223)
at SafeSubscriber.next (Subscriber.js:172)
at Subscriber._next (Subscriber.js:125)
at Subscriber.next (Subscriber.js:89)
at AngularFireAuth.Subject.next (Subject.js:55)
at AngularFireAuth.ReplaySubject.next (ReplaySubject.js:28)
at AngularFireAuth._emitAuthData (auth.js:131)
at SafeSubscriber._next (auth.js:43)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:223)
(anonymous) @ app.js:20
ZoneDelegate.invoke @ zone.js:232
Zone.run @ zone.js:114
(anonymous) @ zone.js:502
ZoneDelegate.invokeTask @ zone.js:265
Zone.runTask @ zone.js:154
drainMicroTaskQueue @ zone.js:401
database.js:53 FIREBASE WARNING: Exception was thrown by user callback. Error: permission_denied at /user/[userid]: Client doesn't have permission to access the desired data.
at G (http://localhost:4200/main.bundle.js:78638:36)
at Object.G (http://localhost:4200/main.bundle.js:78642:86)
at $g (http://localhost:4200/main.bundle.js:78627:98)
at Pg.g.ud (http://localhost:4200/main.bundle.js:78620:310)
at Ce.ud (http://localhost:4200/main.bundle.js:78522:364)
at cd.Xf (http://localhost:4200/main.bundle.js:78520:281)
at fd (http://localhost:4200/main.bundle.js:78476:464)
at WebSocket.Ia.onmessage (http://localhost:4200/main.bundle.js:78475:245)
at WebSocket.wrapFn [as _onmessage] (http://localhost:4200/main.bundle.js:85967:29)
at ZoneDelegate.invokeTask (http://localhost:4200/main.bundle.js:85534:35)
O @ database.js:53
(anonymous) @ database.js:60
ZoneDelegate.invokeTask @ zone.js:265
Zone.runTask @ zone.js:154
ZoneTask.invoke @ zone.js:335
data.args.(anonymous function) @ zone.js:970
database.js:228 Uncaught Error: permission_denied at /user/[userid]: Client doesn't have permission to access the desired data.
at G (database.js:228)
at Object.G (database.js:232)
at $g (database.js:217)
at Pg.g.ud (database.js:210)
at Ce.ud (database.js:112)
at cd.Xf (database.js:110)
at fd (database.js:66)
at WebSocket.Ia.onmessage (database.js:65)
at WebSocket.wrapFn [as _onmessage] (zone.js:698)
at ZoneDelegate.invokeTask (zone.js:265)