-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
51 lines (43 loc) · 1.34 KB
/
firestore.rules
File metadata and controls
51 lines (43 loc) · 1.34 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Check if the user is authenticated
function isAuthenticated() {
return request.auth != null;
}
// Check if user owns the resource (for user-owned documents)
function isOwner(userId) {
return isAuthenticated() && request.auth.uid == userId;
}
function isAdmin() {
return isAuthenticated() &&
(get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin' ||
(request.auth.token.email == "baha@bahasavage.com" && request.auth.token.email_verified == true));
}
match /users/{userId} {
allow read: if isOwner(userId) || isAdmin();
allow create: if isAuthenticated() && isOwner(userId);
allow update: if isOwner(userId) || isAdmin();
}
match /properties/{propertyId} {
allow read: if true;
allow write: if isAdmin();
}
match /courses/{courseId} {
allow read: if true;
allow write: if isAdmin();
}
match /nonprofits/{nonprofitId} {
allow read: if true;
allow write: if isAdmin();
}
match /blogs/{blogId} {
allow read: if true;
allow write: if isAdmin();
}
match /social_posts/{postId} {
allow read: if isAdmin();
allow write: if isAdmin();
}
}
}