forked from OthmanAdi/BarbersBuddies_Onlineshop_maker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
67 lines (58 loc) · 2.28 KB
/
firestore.rules
File metadata and controls
67 lines (58 loc) · 2.28 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Users: only own data
match /users/{userId} {
allow read: if request.auth != null && request.auth.uid == userId;
allow write: if request.auth != null && request.auth.uid == userId;
}
// Barber Shops: public read, owner write
match /barberShops/{shopId} {
allow read: if true;
allow create: if request.auth != null;
allow update, delete: if request.auth != null && request.auth.uid == resource.data.ownerId;
}
// Bookings: customer or shop owner access
match /bookings/{bookingId} {
allow read: if request.auth != null &&
(request.auth.token.email == resource.data.userEmail ||
request.auth.uid == resource.data.shopOwnerId);
allow create: if request.auth != null;
allow update, delete: if request.auth != null &&
(request.auth.token.email == resource.data.userEmail ||
request.auth.uid == resource.data.shopOwnerId);
}
// Messages: participants only
match /messages/{messageId} {
allow read, write: if request.auth != null &&
(request.auth.uid == resource.data.customerId ||
request.auth.uid == resource.data.shopId);
allow create: if request.auth != null;
}
// Ratings: public read, authenticated create, author update
match /ratings/{ratingId} {
allow read: if true;
allow create: if request.auth != null;
allow update: if request.auth != null && request.auth.uid == resource.data.userId;
}
// Notifications: own notifications only
match /notifications/{notificationId} {
allow read, write: if request.auth != null &&
request.auth.uid == resource.data.userId;
}
// Notification preferences: own settings only
match /notificationPreferences/{prefId} {
allow read, write: if request.auth != null && request.auth.uid == prefId;
}
// Shop names: read only for checking availability
match /shopNames/{docId} {
allow read: if request.auth != null;
allow write: if false;
}
// Deleted accounts: write only (for cleanup trigger)
match /deletedAccounts/{userId} {
allow write: if request.auth != null && request.auth.uid == userId;
allow read: if false;
}
}
}