【发布时间】:2018-12-29 16:34:24
【问题描述】:
我正在尝试将数据推送到我的数据库,并且我想检查推送数据的所有者 ID 是否与推送它的人的 uid 相同。我得到许可被拒绝。我不知道如何编写推送数据的安全规则,也找不到任何相关信息。数据结构如下所示:
Shops{
"Shop1PushId" : {
"ShopCredentials" : {
"Owner" : "ownerUID"
}
}
"Shop2PushId" : {
...
}
这是我正在推动的对象。
{
"ShopCredentials" : {
"Owner" : "owner_id",
"Another" : "another thing"
}
}
这是我的 Firebase 规则:
"Shops" : {
".read" : true,
".write" : "newData.child('ShopCredentials').child('Owner').val() === auth.uid"
}
android studio 中的代码:
DatabaseReference shopsRef = database.getReference("Shops");
shopsRef.push().child("ShopCredentials").child("Owner").setValue(shopData.getShopOwner());
【问题讨论】:
标签: android firebase firebase-realtime-database firebase-security