-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
37 lines (33 loc) · 1.1 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
rules_version = '2'
service cloud.firestore {
match /databases/{database}/documents {
match /rooms/{roomID}/messages/{messageID} {
allow read: if userInChat(roomID) && userLogedIn() && !userBlocked()
allow create: if userInChat(roomID) && userLogedIn()
&& sameUserID() && !userBlocked()
}
match /rooms/{roomID}/users_on_page/{userDoc} {
allow read: if userLogedIn() && !userBlocked()
}
match /users/{userID} {
allow read,write: if request.auth.uid == userID && !userBlocked()
}
function userLogedIn() {
return request.auth.uid !=null
}
function userInChat(roomID) {
return roomID == get(/databases/$(database)/documents
/users/$(request.auth.uid)).data.chat_id
}
function emailVerified() {
return request.auth.token.email_verified;
}
function sameUserID(){
//return request.auth.uid == "hzE5avawJEaMY7KqfO59KAAaGZm1"
return request.resource.data.user_uid == request.auth.uid
}
function userBlocked() {
return exists(/databases/$(database)/documents/banned_uids/$(request.auth.uid))
}
}
}