MarKevis Williams
unread,Jun 4, 2024, 10:18:18 AMJun 4Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Firebase Google Group
{
"rules": {
".read": "auth != null", // Make sure to restrict access to authenticated users for other paths not mentioned explicitly
"events": {
".read": true, // Anyone can view events
".write": "auth != null", // Only authenticated users can create or attend events
"$eventId": {
// Allow event creation for authenticated users
".write": "auth != null && (!data.exists() || data.child('createdBy').val() == auth.uid)",
// Restrict updates and deletes to the event creator
".validate": "newData.hasChildren(['name', 'date', 'createdBy'])",
"createdBy": {
".validate": "newData.isString() && newData.val() == auth.uid"
},
// Only the event creator can edit or delete the event
".write": "auth != null && (data.exists() ? data.child('createdBy').val() == auth.uid : true)",
// Logic for attending events (attendees will be stored in an array or map)
"attendees": {
"$userId": {
// Only the user can add or remove themselves from the attendees list
".write": "auth != null && $userId == auth.uid"
}
},
// Define nested chatroom for each event
"chatroom": {
"$messageId": {
".read": true, // Anyone can read chat messages
".write": "auth != null", // Only authenticated users can post messages
"user": {
".validate": "newData.isString() && newData.val() == auth.uid"
},
"message": {
".validate": "newData.isString() && newData.val().length > 0"
},
// Only the message poster can edit or remove their message
".write": "auth != null && (data.exists() ? data.child('user').val() == auth.uid : true)"
}
}
}
}
}
}