-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
firestore.rules
54 lines (48 loc) · 2.45 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
52
53
54
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Common
function authenticated() { return request.auth.uid != null; }
function eventData(eventId) { return get(/databases/$(database)/documents/events/$(eventId)).data; }
function isAdmin(data) { return data.owner == request.auth.uid || request.auth.uid in data.members;}
function isSuperAdmin(userId) { return exists(/databases/$(database)/documents/admins/users/admins/$(userId)); }
match /events/{eventId} {
allow read: if authenticated() && (isAdmin(resource.data) || isSuperAdmin(request.auth.uid));
allow create: if authenticated();
allow write: if authenticated() && isAdmin(resource.data);
match /sessions/{sessionId} {
allow read: if authenticated() && isAdmin(eventData(eventId));
allow write: if authenticated() && isAdmin(eventData(eventId));
}
match /sessionsTemplate/{sessionId} {
allow read: if authenticated() && isAdmin(eventData(eventId));
allow write: if authenticated() && isAdmin(eventData(eventId));
}
match /speakers/{speakerId} {
allow read: if authenticated() && isAdmin(eventData(eventId));
allow write: if authenticated() && isAdmin(eventData(eventId));
}
match /sponsors/{sponsorId} {
allow read: if authenticated() && isAdmin(eventData(eventId));
allow write: if authenticated() && isAdmin(eventData(eventId));
}
match /team/{memberId} {
allow read: if authenticated() && isAdmin(eventData(eventId));
allow write: if authenticated() && isAdmin(eventData(eventId));
}
match /faq/{category=**} {
allow read: if authenticated() && isAdmin(eventData(eventId));
allow write: if authenticated() && isAdmin(eventData(eventId));
}
match /schedule/{scheduleId} {
allow read: if authenticated() && isAdmin(eventData(eventId));
allow write: if authenticated() && isAdmin(eventData(eventId));
}
}
match /admins/users/admins/{userId} {
allow read: if authenticated() && isSuperAdmin(request.auth.uid);
allow write: if false;
allow create: if false;
}
}
}