forked from Unbound-Legends/RPG-Web-Character-Creator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firestore.rules
51 lines (42 loc) · 1.52 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
service cloud.firestore {
match /databases/{database}/documents {
// Make sure the uid of the requesting user matches name of the user
// document. The wildcard expression {userId} makes the userId variable
// available in rules.
function selfOrAllowed(userId) {
return isSelf(userId) || isAllowed(userId);
}
function isSelf(userId){
return request.auth.uid != null && request.auth.uid == userId;
}
function isAllowed(userId){
return request.auth.uid != null &&
request.auth.uid in get(/databases/$(database)/documents/users/$(userId)).data.allowedUsers
;
}
match /users/{userId}/data/{document=**} {
allow read, write: if selfOrAllowed(userId);
}
match /users/{userId}/customData/{document=**} {
allow read, write: if selfOrAllowed(userId);
}
match /vehicleDB/{document} {
function vehicleData() {
return get(/databases/$(database)/documents/vehicleDB/$(document)).data
}
allow create: if request.auth.uid != null;
allow read: if request.auth.uid != null;
allow write: if request.auth.uid in vehicleData().write;
match /data/{type} {
allow read: if request.auth.uid != null;
allow write: if request.auth.uid in vehicleData().write;
}
}
match /userDB/{document} {
allow write: if request.resource.data.uid == request.auth.uid;
}
match /botmessages/{userId}/rolls/{document=**} {
allow read, write: if selfOrAllowed(userId);
}
}
}