-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.rules.json
More file actions
49 lines (49 loc) · 2.21 KB
/
database.rules.json
File metadata and controls
49 lines (49 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid || $uid.matches(/^guest_/)",
".write": "$uid === auth.uid || ($uid.matches(/^guest_/) && newData.child('uid').val() === $uid && newData.child('isGuest').val() === true)",
".validate": "newData.hasChildren(['uid', 'displayName', 'isGuest']) || !newData.exists()"
}
},
"cleanup": {
"lock": {
".read": true,
".write": true
}
},
"rooms": {
".read": "true",
"$roomId": {
".write": "!data.exists() || data.child('hostUid').val() === auth.uid || data.child('hostUid').val().matches(/^guest_/) || (auth != null && data.child('players').child(auth.uid).exists()) || data.child('players').hasChild(newData.child('hostUid').val())",
".validate": "newData.hasChildren(['hostUid', 'gameMode', 'status'])",
"players": {
"$playerId": {
".write": "$playerId === auth.uid || $playerId.matches(/^guest_/) || root.child('rooms').child($roomId).child('hostUid').val() === auth.uid || root.child('rooms').child($roomId).child('hostUid').val() === $playerId"
}
},
"gameState": {
".write": "root.child('rooms').child($roomId).child('hostUid').val() === auth.uid || root.child('rooms').child($roomId).child('hostUid').val().matches(/^guest_/)"
},
"chat": {
".read": "true",
"$messageId": {
".write": "(auth != null && root.child('rooms').child($roomId).child('players').child(auth.uid).exists()) || (newData.child('senderId').val().matches(/^guest_/) && root.child('rooms').child($roomId).child('players').hasChild(newData.child('senderId').val()))",
".validate": "newData.hasChildren(['senderId', 'displayName', 'message', 'timestamp']) && newData.child('message').isString() && newData.child('message').val().length > 0 && newData.child('message').val().length <= 500"
}
}
}
},
"gameModes": {
".read": true,
".write": false
},
"presence": {
"$uid": {
".read": true,
".write": "$uid === auth.uid || ($uid.matches(/^guest_/) && (!newData.exists() || newData.child('uid').val() === $uid))"
}
}
}
}