Solution1: Add a user's uid in the comment. Use that uid to match the current logged-in user's uid to show delete button in your UI. data structure for comments: [{uid, name, photoUrl, rating, text}]
Solution2: The above way should work but essentially all users had delete access to anyone's comment.. it's just that you're not showing the mechanism in UI. for better security I guess you should look at https://firebase.google.com/docs/database/security something like should work
{
"rules": {
"items": {
"$item_id" : {
"comments": {
"$comment_id": {
".read": "auth != null",
".write": "auth != null && (data.child('uid').exists() ? (data.child('uid').val() == auth.uid) : true)"
}
}
}
}
}
}
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.