-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules.js
More file actions
110 lines (89 loc) · 3.15 KB
/
rules.js
File metadata and controls
110 lines (89 loc) · 3.15 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isAdmin() {
let email = request.auth.token.email;
return get(/databases/$(database)/documents/users/$(email)).data.type == 2 || get(/databases/$(database)/documents/users/$(email)/system/Default).data.admin == true;
}
function isKiosk() {
let email = request.auth.token.email;
return get(/databases/$(database)/documents/users/$(email)).data.type == 3;
}
function getParticipantKey() {
let email = request.auth.token.email;
return email.replace("\\.", "").replace("@", "");
}
function isDevAdmin() {
let email = request.auth.token.email;
return get(/databases/$(database)/documents/users_dev/$(email)).data.type == 2 || get(/databases/$(database)/documents/users_dev/$(email)/system/Default).data.admin == true;
}
function isDevKiosk() {
let email = request.auth.token.email;
return get(/databases/$(database)/documents/users_dev/$(email)).data.type == 3;
}
function isCurrentUser(email) {
return email == request.auth.token.email;
}
function isAuthenticated() {
return request.auth != null;
}
match /event/{eventId} {
allow read: if isAdmin() ||
isKiosk() ||
resource.data.participants == {} ||
resource.data.participants[getParticipantKey()] != null ||
resource.data.guide.email == request.auth.token.email;
allow write: if isAdmin();
}
match /media/{mediaId} {
allow read, write: if isAdmin();
}
match /event_dev/{eventId} {
allow read: if isDevAdmin() ||
isDevKiosk() ||
resource.data.participants == {} ||
resource.data.participants[getParticipantKey()] != null ||
resource.data.guide.email == request.auth.token.email;
allow write: if isDevAdmin();
}
match /media_dev/{mediaId} {
allow read, write: if isDevAdmin();
}
match /locations/{locationId} {
allow read: if true;
allow write: if isAdmin();
}
match /locations_dev/{locationId} {
allow read: if true;
allow write: if isDevAdmin();
}
match /guides_dev/{guideId} {
allow read: if true;
allow write: if isDevAdmin();
}
match /users_dev/{email} {
allow read: if isCurrentUser(email) || isDevAdmin() ||
isDevKiosk() && resource.data.showInKiosk == true;
allow create: if false;
allow update: if isDevAdmin();
match /system/{docID} {
allow read, write: if isDevAdmin();
}
match /personal/{docID} {
allow read, write: if isDevAdmin() || isCurrentUser(email);
}
}
match /users/{email} {
allow read: if isCurrentUser(email) || isAdmin() ||
isKiosk() && resource.data.showInKiosk == true;
allow create: if false;
allow update: if isAdmin();
match /system/{docID} {
allow read, write: if isAdmin();
}
match /personal/{docID} {
allow read, write: if isAdmin() || isCurrentUser(email);
}
}
}
}