首页 > 解决方案 > Cloud FireStore基于数组元素id的数组安全规则

问题描述

我有一个名为的文档challenge,其中有一个名为participants. 每个participant基本上都是一个user包含一些额外信息的文档,例如scorereps。我正在使用arrayRemove(participant)arrayUnion(updatedPartipant)替换,基本上在他们重做挑战时更新他们的分数。我想编写一个安全规则来检查经过身份验证的用户 uid 是否与更新的 userId 匹配(即阻止一个参与者更改另一个分数)。是否可以编写一条安全规则:

allow update: if request.auth.uid === request.data.id

还是我需要将此数组移动为子集合?

标签: google-cloud-firestorefirebase-security

解决方案


推荐阅读