forked from JullianMQ/Akaru
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
35 lines (28 loc) · 1.16 KB
/
firestore.rules
File metadata and controls
35 lines (28 loc) · 1.16 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 {
// Users collection rules
match /users/{userId} {
// Allow users to read their own user document
allow read: if request.auth != null && request.auth.uid == userId;
// Allow users to write their own user document
allow write: if request.auth != null && request.auth.uid == userId;
}
// Books collection rules
match /book/{bookId} {
// Allow all users to read any book
allow read; // ALLOW PUBLIC ACCESS
// Allow users to modify the userId array to add their uid
allow update: if request.auth != null;
// Disallow creating new books or deleting existing ones
allow create: if false; // No creation allowed
allow delete: if false; // No deletion allowed
}
// Admin rules for all collections
match /{document=**} {
allow read, write: if request.auth != null &&
exists(/databases/$(database)/documents/users/$(request.auth.uid)) &&
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.userRole == "Admin";
}
}
}