-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfirestore.rules
More file actions
31 lines (27 loc) · 1.07 KB
/
firestore.rules
File metadata and controls
31 lines (27 loc) · 1.07 KB
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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function userAllowed(event) {
return
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.event1 == event
|| get(/databases/$(database)/documents/users/$(request.auth.uid)).data.event2 == event
|| get(/databases/$(database)/documents/users/$(request.auth.uid)).data.event3 == event
|| get(/databases/$(database)/documents/users/$(request.auth.uid)).data.event4 == event;
}
match /tests/{test} {
allow read: if request.auth != null && userAllowed(resource.data.event);
allow write: if false;
}
match /tests/{test}/questions/{question} {
allow read: if request.auth != null;
allow write: if false;
}
match /keys/{key} {
allow read, write: if request.auth != null && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == "admin";
}
match /users/{user} {
allow read: if request.auth != null;
allow write: if request.auth != null;
}
}
}