-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfirestore.rules
More file actions
72 lines (64 loc) · 2.09 KB
/
firestore.rules
File metadata and controls
72 lines (64 loc) · 2.09 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isValidUser() {
return exists(/databases/$(database)/documents/users/$(request.auth.uid));
}
match /{document=**} {
allow read: if
request.auth != null;
allow write: if false;
}
match /users/{userId} {
allow delete: if
request.auth.uid == userId;
allow update: if
request.resource.data.diff(resource.data).affectedKeys().hasOnly(['followersCount']) ||
request.auth.uid == userId;
allow write: if
debug(request.auth) != null &&
debug(resource) == null &&
userId == request.auth.uid;
}
match /events/{eventId} {
allow delete: if
request.auth.uid == resource.data.organiser &&
isValidUser();
allow update: if
request.resource.data.diff(resource.data).affectedKeys().hasOnly(['followersCount']) ||
(request.auth.uid == resource.data.organiser &&
!(request.resource.data.facebookId in resource.data) &&
isValidUser());
allow write: if
request.auth != null && resource == null &&
isValidUser();
}
match /artists/{artistId} {
allow delete: if
request.auth.uid == resource.data.userId &&
isValidUser();
allow update: if
request.resource.data.diff(resource.data).affectedKeys().hasOnly(['followersCount']) ||
(request.auth.uid == resource.data.userId &&
resource.data.spotifyId == request.resource.data.spotifyId &&
resource.data.userId == request.auth.uid &&
isValidUser());
allow write: if
request.auth != null && resource == null &&
isValidUser();
}
match /following/{userId}/{document=**} {
allow delete: if
request.auth.uid == userId;
allow update: if
request.auth.uid == userId;
allow write: if
request.auth != null &&
resource == null &&
userId == request.auth.uid;
}
match /participation/{participationId} {
allow write: if true;
}
}
}