-
Notifications
You must be signed in to change notification settings - Fork 304
/
firestore_rules.txt
53 lines (49 loc) · 1.59 KB
/
firestore_rules.txt
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
44
45
46
47
48
49
50
51
52
53
service cloud.firestore {
match /databases/{database}/documents {
function isAdmin() {
return exists(/databases/$(database)/documents/admin/$(request.auth.uid))
}
match /users/{user} {
allow read: if true;
allow write, update: if request.auth.uid == user;
allow write, update: if isAdmin();
}
match /posts/{user}/userPosts {
allow read: if true;
allow write: if request.auth.uid == user;
allow write, update: if isAdmin();
}
match /posts/{user}/userPosts/{postId} {
allow read: if true;
allow write: if request.auth.uid == user;
allow write, update: if isAdmin();
}
match /posts/{user}/userPosts/{postId}/likes/{likeId} {
allow read: if true;
allow write: if request.auth.uid == likeId;
allow write, update: if isAdmin();
}
match /posts/{user}/userPosts/{postId}/comments/{commentId} {
allow read: if true;
allow write: if request.auth.uid != null;
allow write, update: if isAdmin();
}
match /feed/{documents=**}{
allow read, write: if request.auth.uid != null;
}
match /following/{user}/userFollowing/{following} {
allow read: if true;
allow write: if user == request.auth.uid;
}
match /admin/{documents=**}{
allow write, update, read: if false;
}
match /chats/{chatId}{
allow read, update: if request.auth.uid in resource.data.users;
allow write: if request.auth.uid != null;
}
match /chats/{chatId}/messages/{documents=**}{
allow read, write: if true;
}
}
}