-
Notifications
You must be signed in to change notification settings - Fork 5
/
firestore.rules
73 lines (51 loc) · 1.54 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function signedIn() {
return request != null && request.auth != null && request.auth.uid != null;
}
match /games/{gameId} {
allow read: if true;
allow create: if signedIn()
allow update, delete: if signedIn() && request.auth.uid in resource.data.hosts;
match /messages/{messagesId} {
allow read: if true;
allow write: if signedIn();
}
match /players/{playerId} {
allow read: if true;
allow write: if request.auth.uid == playerId;
}
}
match /quizzes/{quizId} {
function isHost() {
return signedIn() && request.auth.uid in get(/databases/$(database)/documents/games/$(quizId)).data.hosts
}
allow read: if signedIn();
allow write: if isHost();
match /rounds/{roundId} {
allow read: if signedIn();
allow write: if isHost();
match /results/{resultId} {
allow read: if signedIn();
}
match /questions/{questionId} {
allow read: if signedIn();
allow write: if isHost();
match /choices/{choiceId} {
allow read: if isHost();
allow write: if isHost();
}
match /answers/{answerId} {
allow read: if signedIn();
allow write: if signedIn();
}
}
}
}
match /users/{userId} {
allow read: if true;
allow write: if request.auth.uid == userId;
}
}
}