-
Notifications
You must be signed in to change notification settings - Fork 2
/
firestore.rules
37 lines (33 loc) · 965 Bytes
/
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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isOwner(res) {
return res.data.createdBy == request.auth.uid
}
// Public products
match /products/{productsId} {
allow read;
allow write: if false;
}
// Private user profiles
match /users/{userId} {
allow read;
allow write: if request.auth.uid == userId;
}
// Public user profiles
match /users_public/{userId} {
allow read;
allow write: if false; // only written to by indexUser cloud function
}
// Needs
match /needs/{needId} {
// Only needs you own can be viewed
allow create: if isOwner(request.resource);
allow read, update, delete: if isOwner(resource);
// Rules apply to all child collections
match /{allChildren=**} {
allow read, write: if isOwner(get(/databases/$(database)/documents/needs/$(needId)));
}
}
}
}