-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirestore.rules
43 lines (37 loc) · 1.23 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
41
42
43
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{documents=**} {
allow read, write: if false;
}
function isRequester(uid) {
return request.auth != null && request.auth.uid == uid;
}
match /profiles/{profileUid} {
allow read;
allow create: if
'birthDate' in request.resource.data &&
'bio' in request.resource.data &&
'gender' in request.resource.data &&
'name' in request.resource.data &&
'language' in request.resource.data &&
'fluency' in request.resource.data &&
'username' in request.resource.data;
allow update, delete: if isRequester(profileUid);
}
match /chats/{chatUid} {
function inChat() {
return request.auth != null && request.auth.uid in get(/databases/$(database)/documents/chats/$(chatUid)).data.members;
}
allow create;
allow read: if inChat();
match /messages/{messageUid} {
allow read, create: if inChat();
allow update, delete: if request.auth != null && resource.data.author == request.auth.uid;
}
match /readReceipts/{userUid} {
allow read, write: if isRequester(userUid);
}
}
}
}