What needs to be done?
The database:
{
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"
}
}
]
}
The rules:
"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"
}
}
What is wrong?
You can use the newData
server variable to get the author.uid
property. Then use that to check it against auth.uid
.
"items": {
".read": true,
"$item": {
".write": "newData.child('author/uid').val() === auth.uid || auth.provider === 'password'"
}
}
You also had the word or
in the expression rather than ||
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.