-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
firestore.rules
39 lines (33 loc) · 920 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
37
38
39
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isSignedIn() {
return request.auth.uid != null;
}
function isUser(uid) {
return request.auth.uid == uid;
}
function isPlayer(gameID) {
return get(
/databases/$(database)/documents/games/$(gameID)
).data.config.players.hasAny([null, request.auth.uid]);
}
match /names/{nameID} {
allow update, delete: if isUser(
get(/databases/$(database)/documents/names/$(nameID)).data.uid
);
allow read, create: if isSignedIn();
}
match /games/{gameID} {
allow read, create: if isSignedIn();
allow update: if isPlayer(gameID);
match /moves/{move} {
allow read, create, update: if isPlayer(gameID);
allow read: if isSignedIn();
}
}
match /{document=**} {
allow read, write: if false;
}
}
}