2
我是Firebase的新用戶。我正在關注this Tutorial並試圖驗證數據,但不知道爲什麼我的數據未驗證。我想檢查第一個作者表,該用戶是否存在或不存在,然後他能夠寫入。用於在第二個表中寫入數據的Firebase權限用於檢查第一個表中的數據
仿真結果
Type write
Location /posts/1/1
Data { "Authors": { "1": true } }
Auth { "provider": "google", "uid": "1" }
Admin false
寫否認
Line 69 (/posts/1/1)
validate: "root.child('Authors').child(newData.child('Authors').val()).exists()"
我的安全規則是:
"users": {
"$UID": {
".read": "auth.uid == $UID",
".write": "auth.uid == $UID"
}
},
"Authors": {
".read": true,
".write": false
},
"posts": {
".read": true,
"$POSTID": {
".write": "auth.uid != null",
"$UID": {
".validate": "root.child('Authors').child(newData.child('Authors').val()).exists()"
}
}
}
我已經改變了這些線路 ** 「寫 」: 「auth.uid!= NULL」, 「$ UID」:{ 「 .validate」:「root.child( '作者')。 ('作者')。val())。exists()「 } ** 使用此行 **」。write「:」root.child('Authors')。child(auth .uid).exists()「** 現在它工作的很完美。 –
感謝您的答覆* cartant * –