-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
87 lines (72 loc) · 2.52 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// --------------------------------------------------------- Functions
function isAdmin() {
return request.auth.token.admin == true;
}
function isTeacher() {
return request.auth.token.teacher == true;
}
// function isPremium() {
// return request.auth.token.premium == true;
// }
// function isRegistered() {
// return request.auth.token.user == true;
// }
// match /{document=**} {
// allow read, write: if true;
// }
// --------------------------------------------------------- certificates
match /certificates/{certificateId}/{document=**} {
allow read, write: if true;
}
// --------------------------------------------------------- courses
match /courses/{courseId}/{document=**} {
allow read: if resource.data.published == true || isAdmin();
allow create: if isAdmin() || isTeacher();
allow update: if isAdmin();
allow delete: if isAdmin();
}
// --------------------------------------------------------- events
match /events/{eventId}/{document=**} {
allow read: if true;
allow write: if isAdmin();
}
// --------------------------------------------------------- faucets
match /faucets/{faucetId}/{document=**} {
allow read: if true;
allow write: if isAdmin();
}
// --------------------------------------------------------- legals
match /legals/{legalId}/{document=**} {
allow read: if true;
allow write: if isAdmin();
}
// --------------------------------------------------------- polls
match /polls/{pollId}/{document=**} {
allow read: if true;
allow write: if isAdmin();
}
// --------------------------------------------------------- profiles
match /profiles/{profileId}/{document=**} {
allow read: if true;
allow write: if request.auth.uid == profileId || isAdmin();
}
// --------------------------------------------------------- releases
match /releases/{releaseId}/{document=**} {
allow read: if true;
allow write: if isAdmin();
}
// --------------------------------------------------------- stats
match /stats/{statId}/{document=**} {
allow read: if true;
allow write: if isAdmin();
}
// --------------------------------------------------------- tickets
match /tickets/{ticketId}/{document=**} {
allow read: if true;
allow write: if isAdmin();
}
}
}