-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
42 lines (36 loc) · 1.28 KB
/
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Oturum açmış kullanıcıları kontrol et
function isAuthenticated() {
return request.auth != null;
}
// Kullanıcının kendi dokümanı olup olmadığını kontrol et
function isOwner(userId) {
return request.auth.uid == userId;
}
// Herkesin erişebileceği koleksiyonlar
match /shared_drawings/{document=**} {
allow read: if true; // Herkes okuyabilir
allow create, update: if isAuthenticated();
allow delete: if isAuthenticated() && request.auth.uid == resource.data.userId;
}
// Kullanıcı profili için kurallar
match /users/{userId} {
allow read: if true; // Herkes okuyabilir
allow create: if isAuthenticated() && isOwner(userId);
allow update: if isAuthenticated() && isOwner(userId);
allow delete: if isAuthenticated() && isOwner(userId);
// Kullanıcının alt koleksiyonları için kurallar
match /{document=**} {
allow read: if true;
allow write: if isAuthenticated() && isOwner(userId);
}
}
// Diğer koleksiyonlar için varsayılan kurallar
match /{document=**} {
allow read: if true;
allow write: if isAuthenticated();
}
}
}