-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfirestore.rules
More file actions
18 lines (17 loc) · 914 Bytes
/
firestore.rules
File metadata and controls
18 lines (17 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Allow users to read/write their own profiles
match /users/{userId} {
allow get: if request.auth != null && (request.auth.uid == userId || get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin');
allow create, update: if request.auth != null && request.auth.uid == userId;
allow list: if request.auth != null && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin';
}
// Only allow users to read/write their own designs
match /designs/{designId} {
allow read, write: if request.auth != null && request.auth.uid == resource.data.userId;
// Also allow creation if their user ID matches the new document
allow create: if request.auth != null && request.auth.uid == request.resource.data.userId;
}
}
}