mirror of https://github.com/flutter/pinball.git
parent
182e8f56cb
commit
852c14fa60
@ -1,11 +1,10 @@
|
||||
{
|
||||
"firestore": {
|
||||
"rules": "firestore.rules"
|
||||
},
|
||||
"hosting": {
|
||||
"public": "build/web",
|
||||
"site": "ashehwkdkdjruejdnensjsjdne",
|
||||
"ignore": [
|
||||
"firebase.json",
|
||||
"**/.*",
|
||||
"**/node_modules/**"
|
||||
]
|
||||
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
rules_version = '2';
|
||||
service cloud.firestore {
|
||||
match /databases/{database}/documents {
|
||||
match /leaderboard/{userId} {
|
||||
|
||||
function prohibited(initials) {
|
||||
let prohibitedInitials = get(/databases/$(database)/documents/prohibitedInitials/list);
|
||||
return initials in prohibitedInitials;
|
||||
}
|
||||
|
||||
function inCharLimit(initials) {
|
||||
return initials.size() < 4;
|
||||
}
|
||||
|
||||
function isAuthedUser(auth) {
|
||||
return auth.token.aud == "pinball-dev" && auth.token.firebase.sign_in_provider == "anonymous"
|
||||
}
|
||||
|
||||
// Leaderboard can be read if it doesn't contain any prohibited initials
|
||||
allow read: if !prohibited(resource.data.playerInitials);
|
||||
|
||||
// A leaderboard entry can be created if the user is authenticated,
|
||||
// it's 3 characters long, and not a prohibited combination.
|
||||
allow create: if isAuthedUser(request.auth) &&
|
||||
inCharLimit(request.resource.data.playerInitials) &&
|
||||
!prohibited(request.resource.data.playerInitials);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue