我想要一个名为的只读属性suspendedProfile
in a user
具有当前登录用户的读/写访问权限的所有其他属性的文档。有没有办法通过简单的安全规则来做到这一点?
我想到了2个解决方案:
- 禁止修改属性的写入,例如
allow write: if request.resource.data.suspendedProfile == null;
- a
/secure
集合与allow read;
在 - 的里面user
文档
我认为第一个选项更好,所有与用户相关的属性都在一个文档中,但我很想听听您的想法。还有其他更简单的方法来实现这一目标吗?
我想我设法为自己的答案找到解决方案使用 Firebase 文档 https://firebase.google.com/docs/firestore/security/secure-data#the_resource_variable.
// A user can update a product reviews, but they can't change
// the headline.
// Also, they should only be able up update their own product review,
// and they still have to list themselves as an author
allow update: if request.resource.data.headline == resource.data.headline
&& resource.data.authorID == request.auth.userID
&& request.resource.data.authorID == request.auth.userID;
所以就我而言,我只会allow update: if request.resource.data.suspendedProfile == resource.data.suspendedProfile
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)