Skip to content

Commit 2039638

Browse files
author
Your Name
committed
Stripe In Practice Course
1 parent 9158c15 commit 2039638

File tree

1 file changed

+0
-33
lines changed

1 file changed

+0
-33
lines changed

firestore.rules

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

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

5-
function isUserWithId(userId) {
6-
return request.auth.uid == userId;
7-
}
8-
9-
function userOwnsCourse(userId, courseId) {
10-
return exists( /databases/$(database)/documents/users/$(userId)/coursesOwned/$(courseId));
11-
}
12-
13-
function isSubscriber(userId) {
14-
return "pricingPlanId" in get( /databases/$(database)/documents/users/$(userId)).data;
15-
}
16-
17-
match /courses/{courseId} {
18-
allow read: if true;
19-
20-
match /lessons/{lessonId} {
21-
allow read: if userOwnsCourse(request.auth.uid, courseId) || isSubscriber(request.auth.uid);
22-
}
23-
24-
}
25-
26-
match /users/{userId} {
27-
allow read: if isUserWithId(userId);
28-
29-
match /coursesOwned/{courseId} {
30-
allow read: if isUserWithId(userId);
31-
}
32-
33-
}
34-
35-
match /purchaseSessions/{purchaseId} {
36-
allow read: if resource.data.userId == request.auth.uid;
37-
}
385

396
}
407

0 commit comments

Comments
 (0)