forked from Geovation/plastic-patrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
66 lines (49 loc) · 1.77 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
service cloud.firestore {
match /databases/{database}/documents {
function isAdmin() {
return get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin == true
}
function isModerator() {
return get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isModerator == true
}
function isUser(uid) {
return request.auth.uid == uid
}
function isPublished() {
return resource.data.published == true
}
// anybody can read the photos but only admin can write
match /photos/{photoId} {
// allow read: if request.auth.uid != null;
// allow read: if isModerator() || isAdmin() || resource.data.moderated != null;
allow read: if isPublished() || isModerator()
// allow create: if request.auth.uid != null;
allow create: if true;
allow update: if isModerator();
// allow update: if resource.data.owner_id == request.auth.uid && resource.data.moderated=null
allow write: if isAdmin();
}
// anybody can create a feedback but only login user can update
// only moderator or admin can read and update the feedback
match /feedbacks/{feedback} {
allow create: if true;
allow read: if isModerator() || isAdmin();
allow update: if isModerator() || isAdmin();
//allow update: if resource.data.owner_id == request.auth.uid
// allow delete: if isModerator() || isAdmin();
}
// data written by admin
match /users/{uid} {
allow read: if isAdmin() || isUser(uid);
allow write: if isAdmin();
}
// Collection with system data. The Doc stats contains statistics.
match /sys/stats {
allow read: if true;
}
// some extra config
match /sys/config {
allow read: if true;
}
}
}