-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirestore.rules
30 lines (26 loc) · 987 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read: if request.auth != null;
allow create: if request.auth != null && request.auth.uid == userId;
allow update: if request.auth != null && request.auth.uid == userId;
function isValidUser() {
let user = request.resource.data;
return user.displayName is string
&& user.email is string
&& (user.photoURL is string || user.photoURL == null)
&& user.credits is number
&& (user.friends is list || user.friends == null)
&& (('friendRequests' in user && user.friendRequests.sent is list && user.friendRequests.received is list)
|| !('friendRequests' in user));
}
}
match /chats/{chatId} {
allow read, write: if request.auth != null;
}
match /messages/{messageId} {
allow read, write: if request.auth != null;
}
}
}