-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
74 lines (74 loc) · 3 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read: if true;
allow create: if true;
allow update: if true;
allow delete: if request.auth.uid == resource.data.uid;
}
match /articles/{articleId} {
allow read: if true;
allow create: if true;
allow update: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin == true;
allow delete: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin == true;
}
match /articles/{articleId}/teachers/{teacherId} {
allow read: if true;
allow create: if true;
allow update: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin == true;
allow delete: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin == true;
}
match /articles/{teacherId}/teachers {
allow read: if true;
allow create: if true;
allow update: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin == true;
allow delete: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin == true;
}
match /articles/{articleId}/comments/{valueId} {
allow read: if true;
allow create: if request.auth.uid != null;
allow update: if resource.data.uid == request.auth.uid;
allow delete: if resource.data.uid == request.auth.uid;
}
match /articles/{articleId}/likedUids/{uid} {
allow read: if true;
allow create: if request.auth.uid != null;
allow update: if resource.data.uid == request.auth.uid;
allow delete: if resource.data.uid == request.auth.uid;
}
match /articles/{articleId}/pinnedUids/{uid} {
allow read: if true;
allow create: if request.auth.uid != null;
allow update: if resource.data.uid == request.auth.uid;
allow delete: if resource.data.uid == request.auth.uid;
}
match /users/{uid}/pinnedArticles/{articleId} {
allow read: if true;
allow create: if request.auth.uid != null;
allow update: if resource.data.uid == request.auth.uid;
allow delete: if resource.data.uid == request.auth.uid;
}
match /{path=**}/pinnedUids/{uid} {
allow read: if resource.data.uid == request.auth.uid;
}
match /requests/{id} {
allow read: if true;
allow create: if true;
allow update: if request.auth.uid == resource.data.uid;
allow delete: if request.auth.uid == resource.data.uid;
}
match /requests/{id}/requestComments/{valueId} {
allow read: if true;
allow create: if true;
allow update: if request.auth.uid == resource.data.uid;
allow delete: if request.auth.uid == resource.data.uid;
}
match /articles/{articleId}/students/{uid} {
allow read: if true;
allow create: if true;
allow update: if request.auth.uid == resource.data.uid;
allow delete: if request.auth.uid == resource.data.uid;
}
}
}