-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
40 lines (33 loc) · 1.04 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/{userId} {
function isSignedIn() {
return request.auth != null;
}
function isValidNewUser() {
return resource == null;
}
function isCurrentUser() {
return request.auth.uid == userId;
}
allow read: if isSignedIn();
allow create: if isSignedIn() && isValidNewUser();
allow update, delete: if isSignedIn() && isCurrentUser();
}
match /commitments/{commitmentId} {
function isSignedIn() {
return request.auth != null;
}
function isValidNewCommitment() {
return resource == null && request.auth.uid == request.resource.data.userId;
}
function isUserCommitment() {
return request.auth.uid == resource.data.userId;
}
allow read: if isSignedIn() && isUserCommitment();
allow create: if isSignedIn() && isValidNewCommitment();
allow update, delete: if isSignedIn() && isUserCommitment();
}
}
}