forked from TarkovTracker/TarkovTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firestore.rules
35 lines (29 loc) · 1.17 KB
/
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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function memberOfSameTeam(userId){
let teamroom = get(/databases/$(database)/documents/system/$(request.auth.uid)).data.team;
let targetTeamroom = get(/databases/$(database)/documents/system/$(userId)).data.team;
return teamroom == targetTeamroom
}
function memberOfTeam(){
return request.auth.uid in resource.data.members || request.auth.uid == resource.data.owner;
}
match /system/{userId} {
allow read: if request.auth != null && request.auth.uid == userId;
}
match /token/{tokenId} {
allow read: if (request.auth != null && request.auth.uid == resource.data.owner);
}
match /team/{teamId} {
allow read: if (memberOfTeam());
}
match /progress/{userId} {
allow update, delete, create: if request.auth != null && request.auth.uid == userId;
allow read: if (request.auth != null && request.auth.uid == userId) || (memberOfSameTeam(userId));
}
match /user/{userId} {
allow read, update, delete, create: if request.auth != null && request.auth.uid == userId;
}
}
}