-
Notifications
You must be signed in to change notification settings - Fork 5
/
firestore.rules
33 lines (27 loc) · 794 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
33
service cloud.firestore {
match /databases/{database}/documents {
function auth() {
return request.auth;
}
function isAuthenticated() {
return auth().uid != null;
}
function isUserAuthenticated(userId) {
return auth().uid == userId;
}
function isAdmin() {
return exists(/databases/$(database)/documents/admins/$(auth().uid));
}
match /users/{userId} {
allow get: if isAuthenticated();
allow create, update, delete: if isUserAuthenticated(userId) || isAdmin();
match /videos/{videoId} {
allow read: if isAuthenticated();
allow create, update, delete: if isUserAuthenticated(userId) || isAdmin();
}
}
match /videos/{video} {
allow read: if isAuthenticated();
}
}
}