-
Notifications
You must be signed in to change notification settings - Fork 0
/
firestore.rules
56 lines (41 loc) · 1.71 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
rules_version = '2';
// match /{document=**} {
// allow read, write: if request.time < timestamp.date(2024, 5, 30);
// }
service cloud.firestore {
match /databases/{database}/documents {
match /partite/{partita} {
function isAdmin() {
return request.auth != null &&
get(/databases/$(database)/documents/partite/$(partita)/segreti/$(request.auth.token.email)).data.admin == true;
}
allow read: if true;
allow write: if isAdmin();
match /utenti/{email} {
allow create, read: if request.auth != null && request.auth.token.email == email;
allow write: if request.auth != null && request.auth.token.email == email &&
request.time <= get(/databases/$(database)/documents/partite/$(partita)).data.scadenza;
}
match /utenti/{email} {
allow read: if isAdmin();
allow read: if request.auth != null
&& request.time > get(/databases/$(database)/documents/partite/$(partita)).data.scadenza;
}
match /segreti/{key} {
allow create, read, write: if isAdmin();
}
}
}
}
// service cloud.firestore {
// match /databases/{database}/documents {
// match /cities/{city} {
// // Make sure a 'users' document exists for the requesting user before
// // allowing any writes to the 'cities' collection
// allow create: if request.auth != null && exists(/databases/$(database)/documents/users/$(request.auth.uid))
// // Allow the user to delete cities if their user document has the
// // 'admin' field set to 'true'
// allow delete: if request.auth != null && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.admin == true
// }
// }
// }