-
Notifications
You must be signed in to change notification settings - Fork 1
/
database-rules.json
60 lines (60 loc) · 2.4 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
{
"rules": {
"level-secrets": {
"$key": {
".read": "true"
}
},
"levels": {
".read": true,
"$level": {
"$sublevel": {
"timesCompleted": {
".validate": "(!data.exists() && newData.val() == 1) || (newData.val() == data.val() + 1)",
".write": true
}
}
}
},
"hall-of-fame": {
".read": true,
"$uid": {
".indexOn": [
"datetime"
],
".write": "!data.exists() && $uid === auth.uid && root.child('users/' + $uid + '/' + newData.child('last-level-index').val() + '/' + newData.child('last-sublevel-index').val() + '/answer').exists()",
".validate": "newData.hasChildren(['nickname', 'comment', 'datetime'])",
"nickname": {
".validate": "newData.isString() && newData.val().length >= 1"
},
"comment": {
".validate": "newData.isString() && newData.val().length >= 1"
},
"datetime": {
".validate": "newData.val() + 10000 >= now && newData.val() - 10000 <= now"
},
"last-level-index": {
".validate": "root.child('levels/' + newData.val()).exists() && !root.child('levels/' + (newData.val() + 1)).exists()"
},
"last-sublevel-index": {
".validate": "root.child('levels/' + newData.parent().child('last-level-index').val() + '/' + newData.val()).exists() && !root.child('levels/' + newData.parent().child('last-level-index').val() + '/' + (newData.val() + 1)).exists()"
}
}
},
"users": {
"$uid": {
".read": "$uid === auth.uid",
"$level_id": {
"$sublevel_id": {
"answer": {
".write": "$uid === auth.uid && root.child('level-secrets/' + $level_id + '-' + $sublevel_id + '-' + newData.val()).val() == true"
},
"guesses": {
".write": "$uid === auth.uid"
}
}
}
}
}
}
}