-
Notifications
You must be signed in to change notification settings - Fork 0
/
firestore.rules
40 lines (38 loc) · 1.63 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{uid} {
allow read, write: if authUidMatches(uid);
}
match /users/{uid}/meals/{mealUid} {
allow read, write: if authUidMatches(uid);
}
match /users/{uid}/most-used/{mealUid} {
allow read: if authUidMatches(uid);
}
match /users/{uid}/most-used-recipes/{mealUid} {
allow read: if authUidMatches(uid);
}
match /families/{familyId} {
allow get: if request.auth != null && request.auth.uid in resource.data.members;
match /meals/{mealUid} {
allow read, write: if request.auth != null && request.auth.uid in get(/databases/$(database)/documents/families/$(familyId)).data.members;
}
match /suggestions/{uid} {
allow read, write: if request.auth != null && request.auth.uid in get(/databases/$(database)/documents/families/$(familyId)).data.members;
}
match /most-used/{uid} {
allow read: if request.auth != null && request.auth.uid in get(/databases/$(database)/documents/families/$(familyId)).data.members;
}
match /most-used-recipes/{uid} {
allow read: if request.auth != null && request.auth.uid in get(/databases/$(database)/documents/families/$(familyId)).data.members;
}
}
match /meal-themes/{mealThemeId} {
allow read: if request.auth != null;
}
}
function authUidMatches(uid) {
return request.auth != null && request.auth.uid == uid;
}
}