-
Notifications
You must be signed in to change notification settings - Fork 1
/
firestore.rules
40 lines (32 loc) · 1.03 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
38
39
40
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isAuthenticated () {
return request.auth != null
}
function isGuildOwner () {
return isAuthenticated() && resource.data.ownerUid == request.auth.uid
}
function isAdmin () {
return isAuthenticated() && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.admin == true
}
match /guilds/{guild} {
allow create: if isAdmin();
allow read;
allow update: if isGuildOwner() || isAdmin();
allow delete: if isAdmin();
function isRedirectOwner () {
return isAuthenticated() && get(/databases/$(database)/documents/guilds/$(guild)).data.ownerUid == request.auth.uid
}
match /redirects/{redirect} {
allow read: if isRedirectOwner();
}
}
match /{somePath=**}/redirects/{redirect} {
allow read: if isAdmin();
}
match /users/{userId} {
allow read: if isAuthenticated() && request.auth.uid == userId;
}
}
}