-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfirestore.rules
41 lines (39 loc) · 1.31 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read: if true;
allow write: if request.auth != null && request.auth.uid == userId;
}
match /characters/{charId} {
allow read: if true;
allow create: if userOwnsRequest() && hasName();
allow update: if userOwnsDocumentAndRequest() && hasName();
allow delete: if userOwnsDocument();
}
match /ships/{shipId} {
allow read: if true;
allow create: if userOwnsRequest() && hasName();
allow update: if userOwnsDocumentAndRequest() && hasName();
allow delete: if userOwnsDocument();
}
match /parties/{partyId} {
allow read: if true;
allow create: if userOwnsRequest() && hasName();
allow update: if userOwnsDocumentAndRequest() && hasName();
allow delete: if userOwnsDocument();
}
function userOwnsRequest() {
return request.auth != null && request.auth.uid == request.resource.data.owner;
}
function userOwnsDocument() {
return request.auth != null && request.auth.uid == resource.data.owner;
}
function userOwnsDocumentAndRequest() {
return userOwnsDocument() && userOwnsRequest();
}
function hasName() {
return request.resource.data.name is string;
}
}
}