-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
36 lines (33 loc) · 1.02 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isManager() {
return request.auth.uid != null && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.permissions.manager == true
}
function validateNewUser() {
return request.resource.data.permissions.user == true && request.resource.data.permissions.manager == false
}
match /admin/{document=**} {
allow read, write: if isManager()
}
match /pupils/{pupil} {
allow create: if true
allow read, write: if isManager()
}
match /tutors/{tutor} {
allow create: if true
allow read, write: if isManager()
}
match /lessons/{lesson} {
allow create: if true
allow read, write: if isManager()
}
match /users/{uid} {
allow create: if request.auth.uid == uid && validateNewUser()
allow read: if request.auth.uid == uid
match /data/{property} {
allow read, write: if request.auth != null
}
}
}
}