-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
25 lines (22 loc) · 954 Bytes
/
firestore.rules
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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Sprawdź, czy użytkownik jest administratorem
function isAdmin() {
return get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin';
}
match /books/{bookId} {
allow read; // Pozwól na odczyt dla wszystkich użytkowników
allow create, update, delete: if isAdmin(); // Pozwól tylko adminom na dodawanie, aktualizację i usuwanie książek
allow write: if false; // Zablokuj inne operacje zapisu, które nie są utworzeniem, aktualizacją lub usuwaniem
}
match /users/{userId} {
allow read: if request.auth != null && request.auth.uid == userId;
allow write: if request.auth.uid != null && request.auth.uid == userId;
}
match /usernames/{usernameId} {
allow read;
allow write: if request.auth.uid != null && request.auth.uid == usernameId;
}
}
}