-
Notifications
You must be signed in to change notification settings - Fork 0
/
firestore.rules
33 lines (28 loc) · 997 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isSignedIn() {
return request.auth != null && request.auth.uid != null;
}
function recipeIsValid(resourceId) {
let hasId = 'id' in request.resource.data;
let hasName = 'name' in request.resource.data && request.resource.data.name.size() > 0;
let idMatchesResourceId = request.resource.data.id == resourceId;
return hasId && idMatchesResourceId && hasName;
}
match /recipeDetails/{recipeId} {
allow read, delete: if isSignedIn();
allow create, update: if
isSignedIn() &&
recipeIsValid(recipeId);
}
match /aggregates/recipePreviews {
// allow only read because document is updated via a background function
allow read: if isSignedIn();
}
match /aggregates/keywords {
// allow only read because document is updated via a background function
allow read: if isSignedIn();
}
}
}