Skip to content

Commit 0a8c235

Browse files
author
Your Name
committed
Stripe In Practice Course
1 parent 3e52935 commit 0a8c235

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

firestore.rules

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@ service cloud.firestore {
22

33
match /databases/{database}/documents {
44

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+
allow read: if isUserWithId(userId);
30+
}
31+
32+
}
533

634
}
735

0 commit comments

Comments
 (0)