Thank you for your continuous support.
I am currently creating chat software on firebase, but the back-end process did not work out as I expected.
I added read and write permissions to the chat room on the database, but I didn't know how to refer to the rule, so I asked you a question.
rule
{
"rules": {
"rooms": {
".read": "auth!=null",
".write": "auth!=null",
"$room_id":{
".read": "root.child('rooms') .child($room_id).child('read').val() == 'true',
".write": "root.child('rooms') .child($room_id).child('write').val() == 'true',
}
}
}
}
Database
{
"rooms": {
"-ROOM_ID_1": {
"admin"—false,
"img_upload": false,
"messages": {
"-MB-NatBV1ybNEUM-DVS": {
"name": "hoge."",
"text": "Test"
}
},
"read"—true,
"room_name": "Room 1",
"write"—true
},
"-ROOM_ID_2": {
"admin"—false,
"img_upload": false,
"messages": {
"-MB-BcDIyABa7Ngw23IM": {
"name": "hoge",
"text": "Test"
},
"-MB-NPjk4xd0h_JZTUjG": {
"name": "hoge",
"text": "Test"
}
},
"read"—true,
"room_name": "Room 2",
"write"—true
}
}
}
I'd like to see the write in the database room from the rule, but I'm having a hard time because I can't.
firebase
I solved myself.
It looks like this because it's improved a little.
Database
{
"admin-users": {
"9k3Uf ------------------------"—true
},
"black-list": {
"MAtSa -------------------"—true
},
"rooms": {
"-MB3l ---------------": {
"admin"—false,
"author":",
"img_upload": false,
"messages": {
"-MB3nu --------------": {
"name": "Haru Haru",
"photoUrl":",
"text": "Test"
}
},
"photoUrl":",
"read"—true,
"room_name": "Room 1",
"write"—true
},
"-MB3m -----------------": {
"admin"—false,
"author":",
"img_upload": false,
"photoUrl":",
"read"—true,
"room_name": "Room 2",
"write"—false
}
}
}
rule
{
"rules": {
"admin-users": {
".read": "auth!=null&&!root.child('black-list').child(auth.uid).exists(),
".write": "root.child('admin-users').child(auth.uid).exists(),
},
"black-list": {
".read": "auth!=null&&!root.child('black-list').child(auth.uid).exists(),
".write": "root.child('admin-users').child(auth.uid).exists(),
},
"rooms": {
".read": "root.child('admin-users') .child(auth.uid).exists()||auth!=null&&!root.child('black-list') .child(auth.uid).exists(),
"$room_id":{
".read": "root.child('admin-users').child(auth.uid).exists()||auth!=null&&!root.child('black-list').child(auth.uid).exists()&data.child('read') .value(true"
".write": "root.child('admin-users').child(auth.uid).exists()||auth!=null&&!root.child('black-list').child(auth.uid).exists()&data.child('write').value"
}
}
}
}
578 Understanding How to Configure Google API Key
620 Uncaught (inpromise) Error on Electron: An object could not be cloned
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.