-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
36 lines (29 loc) · 1012 Bytes
/
firestore.rules
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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// by default disallow
match /{document=**} {
allow read, write: if false;
}
match /User/{userId}/{document=**} {
allow read, write: if request.auth != null;
}
match /Game/{gameId}/{document=**} {
allow read: if request.auth != null;
allow write: if request.auth != null;
}
//chat
match /messages/{docId} {
allow read: if request.auth.uid != null;
allow create: if canCreateMessage();
}
function canCreateMessage() {
let isSignedIn = request.auth.uid != null;
let isOwner = request.auth.uid == request.resource.data.uid;
let isNotLong = request.resource.data.text.size() < 255;
let isNow = request.time == request.resource.data.createdAt;
let isNotBanned = /User/$(request.auth.uid)/isChatBanned == false;
return isSignedIn && isOwner && isNotLong && isNow && isNotBanned;
}
}
}