Connect your Firebase project to enable login, skins & online matches.
Project Settings → General → Your apps → Web app → SDK setup & configuration (Config).
// Hardened Realtime Database rules — deployed automatically from
// database.rules.json with `firebase deploy`. Only paste manually if this
// app points at a DIFFERENT Firebase project than the one you deploy from.
{
"rules": {
"rooms": {
".read": "auth != null",
".indexOn": ["ts"],
"$roomId": {
".write": "auth != null && ((!data.exists() && newData.hasChildren(['ts']) && !newData.hasChildren(['events']) && !newData.hasChildren(['players'])) || (data.exists() && newData.hasChildren(['ts']) && newData.child('createdAt').val() == data.child('createdAt').val() && !newData.hasChildren(['events'])) || (data.exists() && !newData.exists() && !data.child('players').hasChildren()))",
"seed": {
".write": "auth != null && !data.exists()",
".validate": "newData.isNumber() && newData.val() >= 0 && newData.val() < 2147483648"
},
"players": {
"$uid": {
".write": "auth != null && ($uid === auth.uid || (!newData.exists() && now - data.child('t').val() > 30000))"
}
},
"events": {
".read": "auth != null",
".indexOn": ["tMs"],
"$eventId": {
".write": "auth != null && ((!data.exists() && newData.child('by').val() === auth.uid) || (!newData.exists() && (data.child('by').val() === auth.uid || now - data.child('tMs').val() > 120000)))"
}
}
}
}
}
}
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{uid} {
allow read: if request.auth != null;
allow write: if request.auth != null && request.auth.uid == uid;
allow delete: if request.auth != null && request.auth.uid == uid;
}
}
}