Skip to content
This repository was archived by the owner on Mar 2, 2021. It is now read-only.

Commit 07002ba

Browse files
committed
Do not allow future channel.created dates
and fix indention
1 parent 74f05f4 commit 07002ba

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

database.rules.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
// so instead we just prevent a user to add to himself a radio that already
4949
// has tracks in -> so no radio hijack
5050
".validate": "root.child('channels').child($channelID).exists() && !root.child('users').child(auth.uid).child('channels').child($channelID).exists() && !root.child('channels').child($channelID).child('tracks').exists()"
51-
}
51+
}
5252
}/*,
5353
"$other": {
5454
".validate": false
@@ -66,18 +66,18 @@
6666
// write: only logged-in-user without a user settings can create a new one to himself
6767
".read": "auth != null && (data.child('user').val() === auth.uid)",
6868
".write": "auth != null && ((data.child('user').val() === auth.uid) || (root.child('users').child(auth.uid).hasChild('settings') === false))",
69-
".validate": "newData.hasChild('user')",
69+
".validate": "newData.hasChild('user')",
7070
"user": {
7171
".validate": "newData.val() === auth.uid"
7272
},
7373
"isRemoteActive": {
7474
".validate": "newData.isBoolean()"
7575
},
76-
"playedChannels": {
77-
"$channel": {
76+
"playedChannels": {
77+
"$channel": {
7878
".validate": "newData.isBoolean() && root.child('channels').child($channel).exists()"
79-
}
80-
},
79+
}
80+
},
8181
"$other": {
8282
".validate": false
8383
}
@@ -105,7 +105,8 @@
105105
},
106106
"created": {
107107
// Ensure type::number and that you can not update it
108-
".validate": "data.exists() && data.val() === newData.val() || newData.val() > now - 1000"
108+
// OR allow a timestamp within the last second
109+
".validate": "data.exists() && data.val() === newData.val() || (newData.val() >= now -1000 && newData.val() <= now)"
109110
},
110111
"updated": {
111112
// Ensure type::number and that you can not update it

0 commit comments

Comments
 (0)