-
Notifications
You must be signed in to change notification settings - Fork 26
/
rules.json
84 lines (74 loc) · 2.22 KB
/
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
{
"rules": {
".write": "auth !== null && auth.uid === 'server'",
"currentGame": {
".read": true
},
"events": {
".read": true,
"$event": {
".validate": "newData.hasChildren(['imageUrl', 'text', 'type'])",
"imageUrl": {
".validate": "newData.isString()"
},
"text": {
".validate": "newData.isString()"
},
"type": {
".validate": "newData.isString() && (newData.val() === 'newGame' || newData.val() === 'suggestion' || newData.val() === 'move' || newData.val() === 'gameOver')"
},
"$other": {
".validate": "true"
}
}
},
"loggedInUsers": {
// TODO: I'd like to set ".read" to false but I need to have a way to determine how many total
// users there are without looping through each of them, which requires ".read" to be true here.
".read": true,
".write": "auth != null",
"$provider": {
"$uid": {
".validate": "auth.provider == $provider && auth.uid == $uid && newData.hasChildren(['imageUrl', 'userUrl', 'username'])",
"imageUrl": {
".validate": "newData.isString()"
},
"userUrl": {
".validate": "newData.isString()"
},
"username": {
".validate": "newData.isString()"
},
"$other": {
".validate": "false"
}
}
}
},
"suggestions": {
".read": true,
".write": "auth != null && root.child('currentGame').child('whoseTurn').val() == auth.provider",
"$uid": {
".validate": "auth.uid == $uid && newData.hasChildren(['gridIndex', 'rowIndex', 'columnIndex', 'previousSuggestion'])",
"gridIndex": {
".validate": "newData.isNumber()"
},
"rowIndex": {
".validate": "newData.isNumber()"
},
"columnIndex": {
".validate": "newData.isNumber()"
},
"previousSuggestion": {
".validate": "newData.hasChildren(['gridIndex', 'rowIndex', 'columnIndex']) || newData.val() === false"
},
"$other": {
".validate": "false"
}
}
},
"wins": {
".read": true
}
}
}