Repository navigation
Expand file tree
/
Copy pathfirestore.rules
More file actions
69 lines (56 loc) · 2.33 KB
/
Copy pathfirestore.rules
File metadata and controls
69 lines (56 loc) · 2.33 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /chats/{chatId} {
allow read, write: if true;
match /messages/{messageId} {
allow read, write: if true;
}
}
match /users/{userId} {
allow read: if request.auth != null;
allow write: if request.auth.uid == userId;
allow update: if request.auth != null &&
(get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin' ||
request.auth.uid == userId);
match /notifications/{notificationId} {
allow read, update, delete: if request.auth != null && request.auth.uid == userId;
allow create: if request.auth != null;
}
match /favorites/{campaignId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
match /campaigns/{campaignId} {
allow read: if true;
allow create: if request.auth != null &&
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.verificationStatus == 'verified';
allow update: if request.auth != null;
allow delete: if request.auth.uid == resource.data.ngoId;
}
match /donations/{donationId} {
allow read, update: if request.auth != null &&
(request.auth.uid == resource.data.donorId ||
request.auth.uid == resource.data.ngoId ||
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin');
allow create: if request.auth != null &&
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.verificationStatus == 'verified';
}
match /settings/{document} {
allow read: if true;
allow write: if request.auth != null &&
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin';
}
match /reports/{reportId} {
allow create: if request.auth != null;
allow read, update, delete: if request.auth != null &&
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin';
}
match /admin_logs/{document=**} {
allow read, write: if request.auth != null;
}
match /support_tickets/{document=**} {
allow read, write: if request.auth != null;
}
}
}