我的身份验证令牌包含一个stores属性。该属性是一个数组,其中包含允许用户访问的所有商店的 ID。例如:
stores: ['abc123', 'def456']。
现在,在我的 Firebase 实时数据库中,我正在保存存储特定数据,如下所示:
{
"stores": {
"abc123": {
"data": "mydata"
},
"def456": {
"data": "mydata"
}
}
}
Run Code Online (Sandbox Code Playgroud)
stores如果用户的属性数组包含他们想要访问的 storeID 特定数据,则允许用户访问实时数据库数据。
我希望我的规则如下:
{
"rules": {
"stores": {
"$store_id": {
".read": "auth.token.stores.includes($store_id)"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这不可能。我收到以下错误:
Error saving rules - line 5: type error: function call on target that is not a function.
是否可以在 firebase 规则中搜索令牌属性数组,还是必须使用对象?感谢您的任何答复!