-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfirestore.rules
41 lines (35 loc) · 1.3 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
36
37
38
39
40
41
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /listings/{listingid} {
function canWriteAndUpdate() {
return request.auth.uid != null
&& request.resource.data.owner.uid == request.auth.uid;
}
function canDelete(){
return request.auth.uid != null && resource.data.owner.uid == request.auth.uid;
}
//TODO: TEST AND IMPLEMENT
function canReadIfPublicOrOwnListing(){
return request.auth.uid != null
&& resource.data.active == true
|| resource.data.owner.uid == request.auth.uid
}
//anyone can read any listing
allow read: if true;
// Only the authenticated user who authored the document can write
allow write: if canWriteAndUpdate();
allow delete: if canDelete();
}
match /users/{userId} {
allow read: if true;
allow create: if request.auth != null;
// only user can update their own information
allow update, delete: if request.auth != null && request.auth.uid == userId;
}
// match /{document=**} {
// allow read, write: if request.auth != null && request.time < timestamp.date(2020, 8, 11);
// // allow write: if request.auth != null && request.auth.uid == resource.data.uid
// }
}
}