-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
59 lines (52 loc) · 2.32 KB
/
Copy pathfirestore.rules
File metadata and controls
59 lines (52 loc) · 2.32 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function signedIn() {
return request.auth != null;
}
// Kullanıcı profili
match /users/{userId} {
allow read: if signedIn();
allow create, update: if signedIn() && request.auth.uid == userId;
allow delete: if signedIn() && request.auth.uid == userId;
match /friends/{friendId} {
allow read: if signedIn() && request.auth.uid == userId;
allow write: if signedIn() && (request.auth.uid == userId || request.auth.uid == friendId);
}
}
// Kullanıcı adı → uid (arkadaş aramada tek belge okuma)
match /usernames/{handle} {
allow read: if signedIn();
allow create: if signedIn()
&& request.resource.data.keys().hasOnly(['uid'])
&& request.resource.data.uid == request.auth.uid;
allow update: if signedIn()
&& resource.data.uid == request.auth.uid
&& request.resource.data.uid == request.auth.uid;
allow delete: if signedIn() && resource.data.uid == request.auth.uid;
}
match /friend_requests/{requestId} {
allow read: if signedIn()
&& (resource.data.fromUid == request.auth.uid || resource.data.toUid == request.auth.uid);
allow create: if signedIn()
&& request.resource.data.fromUid == request.auth.uid
&& request.resource.data.status == 'pending';
allow delete: if signedIn()
&& (resource.data.fromUid == request.auth.uid || resource.data.toUid == request.auth.uid);
allow update: if false;
}
match /chats/{chatId} {
allow read: if signedIn() && request.auth.uid in resource.data.memberIds;
allow create: if signedIn() && request.auth.uid in request.resource.data.memberIds;
allow update: if signedIn() && request.auth.uid in resource.data.memberIds;
match /messages/{messageId} {
allow read: if signedIn()
&& request.auth.uid in get(/databases/$(database)/documents/chats/$(chatId)).data.memberIds;
allow create: if signedIn()
&& request.resource.data.senderUid == request.auth.uid
&& request.auth.uid in get(/databases/$(database)/documents/chats/$(chatId)).data.memberIds;
allow update, delete: if false;
}
}
}
}