用户注销“缺少权限或权限不足时,将使用Firebase规则.错误:缺少权限或权限不足" [英] Firebase rules when user log out 'Missing or insufficient permissions. Error: Missing or insufficient permissions'

查看:58
本文介绍了用户注销“缺少权限或权限不足时,将使用Firebase规则.错误:缺少权限或权限不足"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:

'配置文件侦听器错误:缺少权限或权限不足.错误:缺少权限或权限不足.'

'Error with profile listener: Missing or insufficient permissions. Error: Missing or insufficient permissions.'

我的应用程序是使用Reactjs,Redux,Firebase构建的项目经理.您能告诉我为什么用户注销时出现此错误以及如何解决吗?

My app is a project manager built using Reactjs, Redux, Firebase. Could you tell me why it gives this error when the user logs out and how to solve it?

我的规则:

service cloud.firestore {
  match /databases/{database}/documents {
  // Match any {project} document in the 'projects' collection
    match /projects/{project} {
     // Allow signed in users to read write projects
      allow read, write: if request.auth.uid != null; 
    }
    // Match any {user} document in the 'users' collection
    match /users/{user} {
     // Allow users to signup and create an account
      allow create;
      // Allow signed in users to read project details - who create project and when)
      allow read: if request.auth.uid != null;
      // Allow signed in user to update his info only if signed in id == user document id
      allow update, delete: if request.auth.uid == user;
    }
  }
}

推荐答案

如果注销时发生这种情况,则意味着您仍然有

If this happens when you log out, that means you still have an onSnapshot listener attached to a collection that requires a user to be authenticated. When you log out, that listener becomes invalid, and thus the security rules reject it.

要摆脱此消息,请在用户注销之前删除所有此类侦听器.在您的特定情况下,配置文件监听器"似乎有问题.

To get rid of the message, remove all such listeners before the user logs out. In your specific case, it seems to be a problem with the "profile listener".

这篇关于用户注销“缺少权限或权限不足时,将使用Firebase规则.错误:缺少权限或权限不足"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆