-
Notifications
You must be signed in to change notification settings - Fork 0
/
firestore.rules
34 lines (30 loc) · 1.06 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /shipments/{document=**} {
// all can view
allow read: if true;
// only admins can create and edit
allow write: if request.auth.token.admin == true;
}
match /products/{document=**} {
// all can view
allow read: if true;
// only admins can create and edit
allow write: if request.auth.token.admin == true;
}
match /orders/{order} {
// only admin and owner can view
allow read, update: if request.auth.token.admin == true || request.auth.uid == resource.data.userId;
// only admin and owner can create and update
allow create: if request.auth.token.admin == true || request.auth.uid == request.resource.data.userId;
}
match /users/{userId} {
allow read: if request.auth.uid != null;
allow write: if request.auth.uid == userId || request.auth.token.admin == true;
}
match /admins/{userId} {
allow read, write: if request.auth.token.admin == true;
}
}
}