We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3e52935 commit 0a8c235Copy full SHA for 0a8c235
firestore.rules
@@ -2,6 +2,34 @@ service cloud.firestore {
2
3
match /databases/{database}/documents {
4
5
+ function userOwnsCourse(userId, courseId) {
6
+ return exists(/databases/$(database)/documents/users/$(userId)/coursesOwned/$(courseId))
7
+ }
8
+
9
+ function isUserWithId(userId) {
10
+ return request.auth.uid == userId;
11
12
13
+ match /courses/{courseId} {
14
+ allow read: if true;
15
16
+ match /lessons/{lessonId} {
17
+ allow read: if userOwnsCourse(request.auth.uid,courseId)
18
19
20
21
+ match /purchaseSessions/{purchaseId} {
22
+ allow read: if request.auth.uid == resource.data.userId;
23
24
25
+ match /users/{userId} {
26
+ allow read: if isUserWithId(userId);
27
28
+ match /coursesOwned/{courseId} {
29
30
31
32
33
34
}
35
0 commit comments