[英]Custom Firebase Security Rule
需要做什么?
數據庫:
{
items: [
{
title: "some title",
content: "voila, some content",
author: {
uid: "FSDF-SDFSDF-SDFS-SFZE"
}
}, {
title: "some second title title",
content: "voila, some other content",
author: {
uid: "1234-234235-2342-2342"
}
}
]
}
規則:
"items": {
".read": true,
".write": "auth !== null",
"$item": {
".read": true,
".write": "auth !== null && auth.provider === 'password' or root.child('items/' + $item + '/author/uid').val() === auth.uid"
}
}
怎么了?
您可以使用newData
服務器變量來獲取author.uid
屬性。 然后使用它來對auth.uid
進行檢查。
"items": {
".read": true,
"$item": {
".write": "newData.child('author/uid').val() === auth.uid || auth.provider === 'password'"
}
}
您也有單詞or
表達式,而不是||
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.