Firebase 规则:仅为一个用户 uid 在特定节点上启用写入
Firebase rules: enable write on a specific node only for one user uid
我正在尝试仅允许具有“wYr5TO3QhzMIyUK8hj5jAmGE7u53”uid 的用户能够写入支付节点(参见下面的代码)。这可能吗?
这是我的代码:
{
"rules": {
".read": true,
".write": "auth !== null && !newData.hasChild('payement')"
}
}
提前致谢!
当然可以。要允许单个 UID 写入 payement
节点,请使用:
{
"rules": {
".read": true,
"payement": {
".write": "auth !== null && auth.uid === 'wYr5TO3QhzMIyUK8hj5jAmGE7u53'"
}
}
}
我正在尝试仅允许具有“wYr5TO3QhzMIyUK8hj5jAmGE7u53”uid 的用户能够写入支付节点(参见下面的代码)。这可能吗?
这是我的代码:
{
"rules": {
".read": true,
".write": "auth !== null && !newData.hasChild('payement')"
}
}
提前致谢!
当然可以。要允许单个 UID 写入 payement
节点,请使用:
{
"rules": {
".read": true,
"payement": {
".write": "auth !== null && auth.uid === 'wYr5TO3QhzMIyUK8hj5jAmGE7u53'"
}
}
}