对于下面的Firebase规则集。
"users": {
//".read": "(auth != null) && (auth.uid === newData.child('id').val())",
// A list of users and their associated metadata, which can be updated by the single user or a moderator.
"$userId": {
".write": "(auth != null) && (auth.uid === $userId)",
".read": "(auth != null) && (auth.uid === $userId)",
".validate": "($userId === newData.child('id').val())",
"invites": {
// A list of chat invitations from other users, append-only by anyone.
"$inviteId": {
// Allow the user who created the invitation to read the status of the invitation.
".read": "(auth != null) && (auth.uid === data.child('fromUserId').val())",
".write": "(auth != null) && (!data.exists() || $userId === auth.uid || data.child('fromUserId').val() === auth.uid)",
".validate": "newData.hasChildren(['fromUserId','fromUserName','roomId']) && (newData.child('inviteId').val() === $inviteId)"
}
}
}
}
当我尝试使用规则模拟器作为用户2456gd时,/users/2456gd/
下的网址$userId
- 验证步骤成功。但是,如果尝试/users/2456gd/invites/abcd2
- $userId
下的验证步骤失败。
我使用的数据:
{
"id":"2456gd",
"fromUserId":"2456gd",
"fromUserName":"abc",
"roomId":"family",
"inviteId":"abcd2"
}
任何可能的解释?以及如何处理它。
感谢。