-
Notifications
You must be signed in to change notification settings - Fork 2
/
firestore.rules
34 lines (29 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
34
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
match /cards/{doc} {
allow read: if isSignedIn();
allow write: if isSignedIn() && request.auth.uid == request.resource.data.uid;
allow delete, update: if isSignedIn() && request.auth.uid == getCard(doc).data.uid;
}
match /users/{doc} {
allow read: if isSignedIn();
allow write: if isSignedIn() && request.auth.uid == doc;
}
match /friends/{doc} {
allow read: if isSignedIn();
allow write: if isSignedIn() &&
(request.auth.uid == request.resource.data.uid1 || request.auth.uid == request.resource.data.uid2) &&
request.resource.data.uid1 != request.resource.data.uid2;
}
function getCard(doc) {
return get(/databases/$(database)/documents/cards/$(doc));
}
function isSignedIn() {
return request.auth.uid != null;
}
}
}