-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
38 lines (33 loc) · 1.88 KB
/
Copy pathfirestore.rules
File metadata and controls
38 lines (33 loc) · 1.88 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// ─── USERS ───────────────────────────────────────────────────────────────
// Users can only read/write their own profile
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// ─── FOOD ENTRIES ─────────────────────────────────────────────────────────
// Users can only access their own food entries
match /food_entries/{entryId} {
allow read, write: if request.auth != null &&
request.auth.uid == resource.data.userId;
allow create: if request.auth != null &&
request.auth.uid == request.resource.data.userId;
}
// ─── WORKOUT ENTRIES ──────────────────────────────────────────────────────
match /workout_entries/{entryId} {
allow read, write: if request.auth != null &&
request.auth.uid == resource.data.userId;
allow create: if request.auth != null &&
request.auth.uid == request.resource.data.userId;
}
// ─── DAILY SUMMARIES ──────────────────────────────────────────────────────
// Document ID format: "userId_YYYY-MM-DD"
match /daily_summaries/{summaryId} {
allow read, write: if request.auth != null &&
request.auth.uid == resource.data.userId;
allow create: if request.auth != null &&
request.auth.uid == request.resource.data.userId;
}
}
}