This repository has been archived by the owner on Nov 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
/
database.rules.json
149 lines (149 loc) · 5.23 KB
/
database.rules.json
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{
"rules": {
"games": {
"$gameId": {
".read": "auth != null",
"startedAt": {
".write": "auth != null && auth.uid == data.parent().child('host').val() && !data.exists() && newData.exists()",
".validate": "newData.isNumber() && newData.val() == now"
},
"status": {
".write": "auth != null && data.parent().child('users/' + auth.uid).exists() && data.exists() && newData.exists()",
".validate": "newData.isString() && (data.val() == 'waiting' && newData.val() == 'ingame' && auth.uid == data.parent().child('host').val())"
},
"users": {
"$userId": {
".write": "auth != null && auth.uid == $userId && data.parent().parent().child('status').val() == 'waiting'",
".validate": "!newData.exists() || (newData.isNumber() && newData.val() == now)"
}
},
"mode": {
".write": "auth != null && auth.uid == data.parent().child('host').val() && newData.exists()",
".validate": "newData.isString()&& (newData.val() == 'normal' || newData.val() == 'ultraset' || newData.val() == 'setchain')"
},
"enableHint": {
".write": "auth != null && auth.uid == data.parent().child('host').val() && newData.exists()",
".validate": "newData.isBoolean()"
}
}
},
"gameData": {
"$gameId": {
".read": "auth != null",
"events": {
"$eventId": {
".write": "!data.exists() && newData.exists() && auth != null && root.child('games/' + $gameId + '/users/' + auth.uid).exists()",
".validate": "newData.hasChildren(['user', 'time', 'c1', 'c2', 'c3'])",
"user": {
".validate": "newData.isString() && newData.val() == auth.uid"
},
"time": {
".validate": "newData.isNumber() && newData.val() == now"
},
"c1": {
".validate": "newData.isString() && newData.val().matches(/^[0-2]{4}$/)"
},
"c2": {
".validate": "newData.isString() && newData.val().matches(/^[0-2]{4}$/)"
},
"c3": {
".validate": "newData.isString() && newData.val().matches(/^[0-2]{4}$/)"
}
}
}
}
},
"users": {
".indexOn": "connections",
"$userId": {
".read": "auth != null",
".write": "auth != null && (auth.uid == $userId || root.child('users').child(auth.uid).child('admin').val() == true)",
".validate": "newData.hasChildren(['color', 'name'])",
"color": {
".validate": "newData.isString()"
},
"name": {
".validate": "newData.isString() && newData.val().length > 0 && newData.val().length <= 25"
},
"lastOnline": {
".validate": "newData.isNumber() && newData.val() == now"
},
"connections": {
"$connectionId": {
".validate": "newData.isString() || !newData.exists()"
}
},
"banned": {
".validate": "newData.isNumber()"
},
"$other": {
".validate": false
}
}
},
"userGames": {
"$userId": {
".read": "auth != null",
".indexOn": ".value",
"$gameId": {
".write": "auth != null && auth.uid == $userId",
".validate": "!newData.exists() || (newData.isNumber() && newData.val() == root.child('games/' + $gameId + '/createdAt').val())"
}
}
},
"userStats": {
"$userId": {
".read": "auth != null"
}
},
"publicGames": {
".read": "auth != null",
".indexOn": ".value"
},
"chats": {
"$chatId": {
".read": "auth != null",
".indexOn": ["time", "user"],
"$messageId": {
".write": "auth != null && ((!data.exists() && newData.exists()) || (data.exists() && root.child('users').child(auth.uid).child('admin').val() == true))",
".validate": "newData.hasChildren(['user', 'message', 'time'])",
"user": {
".validate": "newData.isString() && newData.val() == auth.uid"
},
"message": {
".validate": "newData.isString() && newData.val().length > 0 && newData.val().length <= 250"
},
"time": {
".validate": "newData.isNumber() && newData.val() == now"
},
"$other": {
".validate": false
}
}
}
},
"lobbyChat": {
".read": "auth != null",
".indexOn": ["time", "user"],
"$messageId": {
".write": "auth != null && ((!data.exists() && newData.exists()) || (data.exists() && root.child('users').child(auth.uid).child('admin').val() == true))",
".validate": "newData.hasChildren(['user', 'message', 'time'])",
"user": {
".validate": "newData.isString() && newData.val() == auth.uid"
},
"message": {
".validate": "newData.isString() && newData.val().length > 0 && newData.val().length <= 250"
},
"time": {
".validate": "newData.isNumber() && newData.val() == now"
},
"$other": {
".validate": false
}
}
},
"stats": {
".read": "auth != null"
}
}
}