-
Notifications
You must be signed in to change notification settings - Fork 0
/
firestore.rules
114 lines (90 loc) · 4.4 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
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
111
112
113
114
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function hasCustomClaim(claim) {
return request.auth.token[claim] || false;
}
function isTeamMember(){
return true;
}
function isClubMember(){
return true;
}
// USERPROFILE
match /userProfile/{userId} {
allow read, update, write: if request.auth != null && request.auth.uid == userId; //Eigene Daten
allow read: if request.auth != null;
}
match /userProfile/{userId}/{collection=**} {
allow read, update, write, create: if request.auth != null && request.auth.uid == userId; //Eigene Daten
}
match /userProfile/{userId}/teamList/{teamId} {
allow delete: if request.auth != null && hasCustomClaim(teamId); //is Team ADMIN
}
match /userProfile/{userId}/teamAdminList/{teamId} {
allow delete,create: if request.auth != null && hasCustomClaim(teamId); //is Team ADMIN
}
match /userProfile/{userId}/clubList/{clubId} {
allow delete: if request.auth != null && hasCustomClaim(clubId); //is Club ADMIN
}
match /userProfile/{userId}/clubAdminList/{clubId} {
allow delete, create: if request.auth != null && hasCustomClaim(clubId); //is Club ADMIN
}
//CLUB
match /club/{clubId} {
allow read: if request.auth != null; //&& exists(/databases/$(database)/documents/userProfile/$(request.auth.uid)/clubList/$(clubId));
}
//TEAM
match /team/{teamId} {
allow read: if request.auth != null; //&& exists(/databases/$(database)/documents/userProfile/$(request.auth.uid)/teamList/$(teamId));
}
//TRAINING STATUS
match /team/{teamId}/trainingList/{trainingId}/memberList/{memberId} {
allow read, write: if request.auth != null && request.auth.uid == memberId; //nur eigenen Status ändern
}
//TRAINING COUNT Anmeldungen
match /team/{teamId}/trainingList/{trainingId=**} {
allow read: if request.auth != null && exists(/databases/$(database)/documents/userProfile/$(request.auth.uid)/teamList/$(teamId)) ;
}
//TRAINING CHANGE / DELETE
match /team/{teamId}/trainingList/{trainingId} {
allow update, delete: if request.auth != null && hasCustomClaim(teamId); //Team Admin
}
// CHAMPIONSHIP STATUS
match /team/{teamId}/championshipList/{championshipId}/memberList/{memberId} {
allow read, write: if request.auth != null && request.auth.uid == memberId; //nur eigenen Status ändern
}
//CHAMPIONSHIP COUNT Anmeldungen
match /team/{teamId}/championshipList/{championshipId=**} {
allow read: if request.auth != null && exists(/databases/$(database)/documents/userProfile/$(request.auth.uid)/teamList/$(teamId))
}
//TEAM MEMBER LIST
match /team/{teamId}/memberList/{memberId} {
allow read: if request.auth != null && exists(/databases/$(database)/documents/userProfile/$(request.auth.uid)/teamList/$(teamId)) ;
}
//TEAM ADMIN LIST
match /team/{teamId}/teamAdminList/{document=**} {
allow read: if request.auth != null && exists(/databases/$(database)/documents/userProfile/$(request.auth.uid)/teamList/$(teamId)) ;
}
//CLUB MEMBER LIST
match /club/{clubId}/memberList/{memberId} {
allow read: if request.auth != null && exists(/databases/$(database)/documents/userProfile/$(request.auth.uid)/clubList/$(clubId)) ;
}
//CLUB ADMIN LIST
match /club/{clubId}/clubAdminList/{document=**} {
allow read: if request.auth != null && exists(/databases/$(database)/documents/userProfile/$(request.auth.uid)/clubList/$(clubId)) ;
}
match /team/{teamId}/requestList {
allow read: if request.auth != null && exists(/databases/$(database)/documents/userProfile/$(request.auth.uid)/teamList/$(teamId)) ;
}
match /club/{clubId}/requestList/{documents=**} {
allow read: if request.auth != null && exists(/databases/$(database)/documents/userProfile/$(request.auth.uid)/clubList/$(clubId)) ;
}
match /requests/{documents=**} {
allow read, write: if request.auth != null ;
}
match /mail { //No ACCESS
allow read, write: if 1==2;
}
}
}