-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
35 lines (28 loc) · 1.17 KB
/
firestore.rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isSignedIn() {
return request.auth.uid != null
}
// Make sure the request has only the specified allowed fields
function editingAllowedFields(allowed) {
let editedKeys = request.resource.data.diff(resource.data).affectedKeys();
return editedKeys.hasOnly(allowed);
}
match /events/{eventID} {
allow read: if true;
// Organizers can create requests only with their own consumer_id
allow create: if request.resource.data.consumer_id == request.auth.uid && isSignedIn()
// Address can't be changed after event creation
allow update: if request.resource.data.address == resource.data.address && isSignedIn()
// Only allow guests to edit these fields
allow update: if editingAllowedFields(["arrivedProviderSpaces", "interestedProviders", "departedProviderSpaces"])
}
match /users/{userID} {
// Anyone is allowed to read the users database
allow read: if true
// Allow users to write only to their own doc
allow write: if request.auth.uid == userID
}
}
}