-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
35 lines (29 loc) · 1.13 KB
/
firestore.rules
File metadata and controls
35 lines (29 loc) · 1.13 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Helper function to check if user is authenticated
function isAuthenticated() {
return request.auth != null;
}
// Helper function to check if user is accessing their own data
function isOwner(userId) {
return isAuthenticated() && request.auth.uid == userId;
}
match /users/{userId} {
// Allow users to read and write their own profile
allow read, write: if isOwner(userId);
}
match /downloads/{downloadId} {
allow read: if isAuthenticated() && resource.data.userId == request.auth.uid;
allow create: if isAuthenticated() && request.resource.data.userId == request.auth.uid;
allow update, delete: if isAuthenticated() && resource.data.userId == request.auth.uid;
}
match /blog_posts/{slug} {
allow read: if true;
allow write: if isAuthenticated() && request.auth.token.email == "rikiruswandi28@gmail.com";
}
match /settings/{docId} {
allow read, write: if isAuthenticated() && request.auth.token.email == "rikiruswandi28@gmail.com";
}
}
}