问题:目前,当我在应用程序中注销时,浏览器控制台中会记录以下错误,
core.es5.js:1020 ERROR Error: permission_denied at /all-posts: Client doesn't have permission to access the desired data.
at Object.webpackJsonp.../../../../@firebase/database/dist/cjs/src/core/util/util.js.exports.errorForServerCode (util.js:513)
at onComplete (SyncTree.js:538)
at Object.onComplete (Repo.js:115)
at PersistentConnection.webpackJsonp.../../../../@firebase/database/dist/cjs/src/core/PersistentConnection.js.PersistentConnection.onListenRevoked_ (PersistentConnection.js:692)
at PersistentConnection.webpackJsonp.../../../../@firebase/database/dist/cjs/src/core/PersistentConnection.js.PersistentConnection.onDataPush_ (PersistentConnection.js:464)
at PersistentConnection.webpackJsonp.../../../../@firebase/database/dist/cjs/src/core/PersistentConnection.js.PersistentConnection.onDataMessage_ (PersistentConnection.js:452)
at Connection.webpackJsonp.../../../../@firebase/database/dist/cjs/src/realtime/Connection.js.Connection.onDataMessage_ (Connection.js:262)
at Connection.webpackJsonp.../../../../@firebase/database/dist/cjs/src/realtime/Connection.js.Connection.onPrimaryMessageReceived_ (Connection.js:256)
at WebSocketConnection.onMessage (Connection.js:157)
at WebSocketConnection.webpackJsonp.../../../../@firebase/database/dist/cjs/src/realtime/WebSocketConnection.js.WebSocketConnection.appendFrame_ (WebSocketConnection.js:197)
在控制台中记录了与权限相关的其他类似错误,这仅用于示例。
Here is snapshot.
我试图找出是否有办法防止以编程方式在浏览器控制台中记录这些类型的错误。
这是我当前的退出代码:
logout() {
this.afAuth.auth.signOut()
.then( () => {
this.router.navigate(['login']);
});
}
答案 0 :(得分:1)
看起来您在Firebase数据库上有需要用户进行身份验证的侦听器。当您向用户签名时,这些侦听器将变为非法,因此Firebase数据库会取消它们并告知您的应用程序有关错误。
为了防止这种情况,请在签署用户之前停止监听,方法是为每个用户调用ref.off()
。