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

Commit 2ef0b70

Browse files
committed
Merge branch 'fix/timestamp'
2 parents 93b893e + 07002ba commit 2ef0b70

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

database.rules.json

Lines changed: 10 additions & 9 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
}
@@ -104,8 +104,9 @@
104104
".validate": "newData.isString() && root.child('channelPublics').child(newData.val()).child('channel').val() == $channelID"
105105
},
106106
"created": {
107-
// Ensure type::timestamp and that you can not update it
108-
".validate": "data.exists() && data.val() === newData.val() || newData.val() == now"
107+
// Ensure type::number and that you can not update it
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
@@ -125,7 +126,7 @@
125126
".validate": "newData.isString() && newData.val().length > 2 && newData.val().length < 100"
126127
},
127128
"title": {
128-
".validate": "newData.isString() && newData.val().length > 2 && newData.val().length < 33"
129+
".validate": "newData.isString() && newData.val().length > 2 && newData.val().length < 32"
129130
},
130131
"tracks": {
131132
"$track": {

0 commit comments

Comments
 (0)