-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirestore.rules
58 lines (54 loc) · 2.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{uid} {
allow read: if true;
allow write: if request.auth.uid == uid && (!('isAdmin' in request.resource.data) || request.resource.data.isAdmin == resource.data.isAdmin);
}
match /posts/{post} {
allow read: if true;
allow create: if request.auth != null && request.resource.data.author == request.auth.uid;
allow delete, update: if request.auth.uid == resource.data.author;
allow update: if request.auth != null &&
request.resource.data.diff(resource.data)
.affectedKeys().hasOnly(['likes', 'amountOfComments'])
match /comments/{comment} {
allow read: if true;
allow create: if request.resource.data.author == request.auth.uid;
allow update, delete: if resource.data.author == request.auth.uid;
}
}
match /games/{game} {
allow write: if false;
allow read: if true;
match /lobbies/{lobbyId} {
allow create, update, read: if true;
allow delete: if request.auth.uid == resource.data.admin;
}
match /games/{gameId} {
allow read: if request.auth.uid in resource.data.players;
allow update: if request.auth.uid in resource.data.players;
allow create: if true;
allow delete: if false;
}
}
match /contestants/{contestant} {
allow read: if true;
allow create: if request.auth != null && request.resource.data.uid == request.auth.uid;
// admin
allow delete, update: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin == true;
match /bongs/{bongId} {
allow read: if true;
// admin
allow create: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin == true;
allow update, delete: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin == true;
}
}
match /settings/{setting} {
allow read;
}
match /{path=**}/bongs/{bongId} {
allow read: if true;
}
}
}