2
我目前正試圖通過檢查最後發佈的時間戳來實現速率限制,然後向其添加+ 60秒,然後檢查它是否更小(<),然後將當前Firebase服務器時間戳(現在)。 它總是返回true並授予訪問權限!
這是我的規則:實時數據庫規則中的Firebase速率限制
{
"rules": {
"posts": {
".read": true,
".write":
"(root.child('users').child(auth.uid).child('lastPost').val() + 60) < now"
}
}
}
這是我的數據庫結構
{
"posts": {
"-KV70ppGGTEtXY4_Q4UC": {
"author": "abcdedef-uid-ojifgoöifjgssgd",
"description": "Thats the post description",
"title": "Thats the post title"
}
},
"users": {
"2uy7323nTodMHcVxeEDJzoexH302": {
"canPost": true,
"email": "[email protected]",
"lastPost": 14776667681,
"profile_picture": "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg",
"username": "Cryptic Pug"
}
}
}
實際上,您需要添加60000,因爲它計數毫秒 –
聽起來像一個答案@VladimirGabrielyan! :-) –