-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
44 lines (40 loc) · 1.21 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
rules_version = "2";
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write:
if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.admin;
}
match /messages/{messageID} {
allow read: if true;
allow create, update:
if /databases/$(database)/documents/users/$(request.auth.uid) ==
request.resource.data.user;
}
match /resources/{resourceID} {
allow read: if true;
allow create, update:
if /databases/$(database)/documents/users/$(request.auth.uid) ==
request.resource.data.user;
}
match /pods/{podID} {
allow read: if true;
allow create, update: if request.auth != null;
}
match /users/{userID} {
allow read, create: if true;
allow update:
if request.auth != null &&
(
resource.data.admin ||
(
request.auth.uid == userID &&
// Line below ensures that they cannot change admin status
resource.data.admin == request.resource.data.admin
)
);
allow delete:
if request.auth != null && (request.auth.uid == userID || resource.data.admin);
}
}
}