This repository has been archived by the owner on Apr 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
database.rules.json
153 lines (149 loc) · 6.42 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
150
151
152
153
{
"rules": {
"collections": {
".read": true,
},
"lies": {
".read": true,
".write": "auth !== null",
".indexOn": [
"timestamp",
"isModerated"
],
"$lieUid": {
"uid": {
".validate": "!data.exists() && newData.isString() && newData.val() === $lieUid"
},
"timestamp": {
".validate": "!data.exists() && newData.isNumber()"
},
"isModerated": {
".validate": "newData.isBoolean() && (root.child('users').child(auth.uid).child('isAdmin').val() === true || newData.val() === false)"
},
"accuser": {
".validate": "auth.provider !== 'anonymous' && !data.exists() && newData.val() === auth.uid"
},
"title": {
".validate": "auth.provider !== 'anonymous' && !data.exists() && newData.isString()"
},
"liar": {
".validate": "auth.provider !== 'anonymous' && !data.exists() && newData.isString()"
},
"text": {
".validate": "auth.provider !== 'anonymous' && !data.exists() && newData.isString()"
},
"votes": {
"liar": {
".validate": "
(!data.exists() && newData.val() === 0)
||
(
data.exists() && newData.val() === data.val() + 1
&&
(
!root.child('users').child(auth.uid).child('votes').child($lieUid).exists()
||
root.child('users').child(auth.uid).child('votes').child($lieUid).val() === 'notLiar'
)
)
||
(
data.exists() && newData.val() === data.val() - 1
&&
root.child('users').child(auth.uid).child('votes').child($lieUid).val() === 'liar'
)
"
},
"notLiar": {
".validate": "
(!data.exists() && newData.val() === 0)
||
(
data.exists() && newData.val() === data.val() + 1
&&
(
!root.child('users').child(auth.uid).child('votes').child($lieUid).exists()
||
root.child('users').child(auth.uid).child('votes').child($lieUid).val() === 'liar'
)
)
||
(
data.exists() && newData.val() === data.val() - 1
&&
root.child('users').child(auth.uid).child('votes').child($lieUid).val() === 'notLiar'
)
"
}
},
"sources": {
".validate": "auth.provider !== 'anonymous' && !data.exists()",
"statements": {
"$key": {
"url": {
".validate": "!data.exists() && newData.isString() && newData.val().contains('//')"
}
}
},
"refutations": {
"$key": {
"url": {
".validate": "!data.exists() && newData.isString() && newData.val().contains('//')"
}
}
},
"confirmations": {
"$key": {
"url": {
".validate": "!data.exists() && newData.isString() && newData.val().contains('//')"
}
}
},
},
"pictures": {
".validate": "auth.provider !== 'anonymous' && !data.exists() && newData.hasChildren(['main'])",
"main": {
"url": {
".validate": "!data.exists() && newData.isString() && newData.val().beginsWith('https://firebasestorage.googleapis.com/v0/b/liarbustr.appspot.com/o/images%2Flies%2F')"
},
"color": {
".validate": "!data.exists() && newData.isString() && newData.val().matches(/^#([0-9a-fA-F]{3}){1,2}$/)"
}
}
}
}
},
"users": {
"$userUid": {
".read": "auth.uid === $userUid",
".write": "!data.exists() || (data.exists() && auth.uid === $userUid)",
"lastLogin": {
".validate": "newData.isNumber()"
},
"email": {
".validate": "newData.isString()"
},
"isAdmin": {
".validate": "newData.isBoolean() && (data.val() === true || newData.val() === false)"
},
"isAnonymous": {
".validate": "newData.isBoolean()"
},
"name": {
".validate": "newData.isString()"
},
"profilePicture": {
".validate": "newData.isString() && (newData.val().length === 0 || newData.val().contains('//'))"
},
"uid": {
".validate": "!data.exists() || data.val() === newData.val()"
},
"votes": {
"$lieUid": {
".validate": "newData.isString() && (newData.val() === 'liar' || newData.val() === 'notLiar')"
}
}
}
}
}
}