我想在suspendedProfile
文档中有一个名为user
的只读属性,其中所有其他属性都具有当前登录用户的读/写访问权限。有没有办法用简单的安全规则来做到这一点?
我想到了两个解决方案:
allow write: if request.resource.data.suspendedProfile == null;
/secure
文件中使用allow read;
的user
集合我认为第一个选项是更好的所有与用户相关的属性都在一个单独的文件中,但我很想听听你的想法。有没有其他更简单的方法来实现这一目标?
我想我找到了自己的答案using Firebase documentation的解决方案。
// 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