ユーザーがログインするたびに、これを実行して自分のデータをusers
ノードに保存します。ページがリダイレクトされるまでFirebaseは私のユーザーに聞いておく意味Angularfire2は一度データを読み取る
FIREBASE WARNING: Exception was thrown by user callback. Error: permission_denied at /users/userID: Client doesn't have permission to access the desired data.
at Error (native)
at G (http://localhost:4200/main.bundle.js:75367:36)
at Object.G (http://localhost:4200/main.bundle.js:75371:86)
at yh (http://localhost:4200/main.bundle.js:75356:98)
at nh.h.wd (http://localhost:4200/main.bundle.js:75349:310)
at af.wd (http://localhost:4200/main.bundle.js:75252:364)
at vd.hg (http://localhost:4200/main.bundle.js:75250:280)
at yd (http://localhost:4200/main.bundle.js:75203:464)
at WebSocket.La.onmessage (http://localhost:4200/main.bundle.js:75202:245)
at WebSocket.wrapFn [as _onmessage] (http://localhost:4200/main.bundle.js:94097:29)
:ユーザがログアウトするたびに不運、私はこのエラーを取得します。だから一度だけ実行してみる必要があります。何か案は?ユーザパネルで
、私はこのコードを持っている: firebaseからデータを取得するために私loadUser()
方法を指し
ngOnInit() {
this.authService.loadUser().subscribe(() => {
this.user = this.authService.userData;
});
}
(私はちょうどテイクを配置しようとした(1)私はまだ、このパーミッションエラーが出ます
logout() {
this.auth.logout();
this.userData = null;
this.isLoggedIn = false;
this.router.navigate(['']);
}
私は思う:):私は単にこれを行う私のログアウトで
loadUser() {
return this.af.database.object('/users/'+this.uid).take(1).map(user => {
this.userData = user;
});
}
this.auth.logout();
の後であってもFirebaseがユーザーとの接続を維持しているためにエラーが発生し、ルーターがナビゲートするまでデータを更新しようとします。だからこそ私はこのアクションを1回だけ実行する必要があります。