-
Notifications
You must be signed in to change notification settings - Fork 7
/
firestore.rules
32 lines (27 loc) · 889 Bytes
/
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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isAuthenticated() {
return request.auth != null && request.auth.uid != null;
}
function isAdmin() {
return get(/databases/$(database)/documents/roles/$(request.auth.uid)).data.role == 'admin'
}
match /users/{userId} {
allow update, delete: if request.auth.uid == userId;
allow read, create: if isAuthenticated();
}
match /roles/{userId} {
allow read: if request.auth.uid == userId;
allow write: if false;
}
match /events/{eventId} {
allow read: if isAuthenticated();
allow write: if isAdmin();
match /suggestions/{suggestionId} {
allow read, create, update: if isAuthenticated();
allow delete: if get(resource.data.userReference).data.uid == request.auth.uid;
}
}
}
}