我正在使用角色(允许读取,写入:如果 request.auth.uid!= null ),当我登录时,我获取数据没问题,但是当我注销用户时,我收到错误:缺少权限或权限不足。首先我认为这是因为我没有取消订阅我尝试过的 Observable (rxjs/operator/takeWhile),即使我使用了异步管道,我也得到了同样的错误。
最佳答案
如果您已注销,则 request.auth.id == null,因此,您的读取规则返回 false。 尝试更改为:
allow read;
allow create: if request.auth.uid != null;
这允许任何人读取并且只有经过身份验证的用户才能创建。您通常只希望作者更新。为此,您需要将文档中作者的 uid 保存为 userid 之类的属性,然后您可以像这样更新规则:
match /myCollection/{document=**} {
allow read;
allow create: if request.auth.uid != null;
allow update: if isOwner();
}
function existingData() {
return resource.data
}
function isOwner() {
return request.auth.uid == existingData().userid;
}
关于angular - 火存储 : Missing or insufficient permissions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49623045/