我有一个定制的FB令牌,它可以解密到以下内容
{
"uid" : "fred"
"d" : {
"roles" : [
"foo",
"bar"
]
}
}现在,我希望锁定数据,以便只有具有foo角色的用户才能访问数据。如何编写Firebase authz规则来做到这一点?我试过这样做,但它不能编译。我认为它不喜欢indexOf()方法。
{
"rules": {
".read": "auth != null && auth.role != null && auth.role.indexOf('foo') > 0",
".write": false,
}给出以下错误:
类型错误:对非函数的目标进行函数调用。
发布于 2015-07-16 14:47:16
我将JSON重构为如下格式:
{
"uid" : "fred"
"d" : {
"roles" : {
"foo" : true,
"bar" : true
}
}
}我的创作规则是
{
"rules": {
".read": "auth != null && auth.role != null && auth.role['foo'] == true",
".write": false,
}https://stackoverflow.com/questions/31439544
复制相似问题