-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
53 lines (45 loc) · 2.15 KB
/
firestore.rules
File metadata and controls
53 lines (45 loc) · 2.15 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// User profiles - private to each user
match /user_profiles/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// Mood entries - private to each user
match /mood_entries/{entryId} {
allow read, write: if request.auth != null && request.auth.uid == resource.data.user_id;
allow create: if request.auth != null && request.auth.uid == request.resource.data.user_id;
}
// Chat conversations - private to each user
match /chat_conversations/{conversationId} {
allow read, write: if request.auth != null && request.auth.uid == resource.data.user_id;
allow create: if request.auth != null && request.auth.uid == request.resource.data.user_id;
}
// Chat messages - private to conversation owner
match /chat_conversations/{conversationId}/messages/{messageId} {
allow read, write: if request.auth != null &&
request.auth.uid == get(/databases/$(database)/documents/chat_conversations/$(conversationId)).data.user_id;
allow create: if request.auth != null &&
request.auth.uid == get(/databases/$(database)/documents/chat_conversations/$(conversationId)).data.user_id;
}
// User progress - private to each user
match /user_progress/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// Challenge progress - private to each user
match /challenge_progress/{progressId} {
allow read, write: if request.auth != null && request.auth.uid == resource.data.user_id;
allow create: if request.auth != null && request.auth.uid == request.resource.data.user_id;
}
// Wellness challenges - public read, admin write only
match /wellness_challenges/{challengeId} {
allow read: if true;
allow write: if false; // Only admins can create challenges via admin SDK
}
// Helpline resources - public read
match /helpline_resources/{resourceId} {
allow read: if true;
allow write: if false; // Only admins can manage resources
}
}
}