-
Notifications
You must be signed in to change notification settings - Fork 1
/
firestore.rules
32 lines (27 loc) · 964 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
26
27
28
29
30
31
32
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isAdmin() {
return request.auth.uid == 'Twt0A27bx9YcG4vu3RTsR7ifJzf2';
}
function isAuthorized(userId) {
return request.auth != null && (userId == request.auth.uid || isAdmin());
}
function isValidText(text) {
return text is string || text == null;
}
function isValidImages(images) {
return (images is list && images.size() <= 4) || images == null;
}
match /tweets/{tweetId} {
allow read, update: if request.auth != null;
allow create: if isAuthorized(request.resource.data.createdBy)
&& isValidText(request.resource.data.text)
&& isValidImages(request.resource.data.images);
allow delete: if isAuthorized(resource.data.createdBy);
}
match /users/{document=**} {
allow read, write: if request.auth != null;
}
}
}