【发布时间】:2021-05-08 21:35:54
【问题描述】:
我的帖子包含用户 ID,例如,用户 ID 为“abcd1234z”的用户的帖子名称为“abcd1234z-1”。如果帖子标题 ($child) 在名称中包含 userId,我无法获得写入规则检查。我尝试了 .contains 和 .matches 选项,但不能正确格式化正则表达式。
{
"rules": {
"cloud": {
"news": {
".read": "auth.uid != null",
".write": "auth.uid != null",
}
},
"forum": {
"posts": {
"$child": {
".read": "auth.uid != null",
".write": "auth.uid != null && $child.matches(/*+request.auth.uid/)"
"$uid": {
".write": "auth.uid != null && $uid === auth.uid",
}
}
}
}
}
}
【问题讨论】:
标签: regex firebase firebase-realtime-database firebase-security