This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 106
/
firestore.rules
59 lines (48 loc) · 1.61 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function getMatch(matchId) {
return get(/databases/$(database)/documents/matches/$(matchId));
}
function getDeck(deckId) {
return get(/databases/$(database)/documents/decks/$(deckId));
}
function isAuthenticated() {
return request.auth != null;
}
match /prompt_terms/{script} {
allow read: if isAuthenticated();
}
match /scripts/{script} {
allow read: if isAuthenticated();
}
match /cards/{card} {
allow read, write: if false;
}
match /decks/{deck_id} {
allow read, write: if false;
}
match /initial_blacklist/{doc} {
allow read: if isAuthenticated();
}
match /match_states/{match_state_id} {
allow read: if isAuthenticated();
allow create: if isAuthenticated()
&& request.auth.uid == getDeck(getMatch(request.resource.data.matchId).data.host).data.userId;
}
match /matches/{match_id} {
allow read: if isAuthenticated();
allow create: if isAuthenticated()
&& request.auth.uid == getDeck(request.resource.data.host).data.userId;
allow update: if isAuthenticated()
&& request.auth.uid == getDeck(request.resource.data.guest).data.userId
&& (resource.data.guest == 'EMPTY' || resource.data.guest == 'RESERVED_EMPTY' || resource.data.guest == 'INVITE');
}
match /score_cards/{score_card} {
allow read, write: if isAuthenticated() && request.auth.uid == score_card;
}
match /config/{doc} {
allow read: if isAuthenticated();
}
}
}