-
Notifications
You must be signed in to change notification settings - Fork 16
/
storage.rules
34 lines (29 loc) · 931 Bytes
/
storage.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
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
function isOwner(userId) {
return request.auth.uid == userId
}
function isSignedIn() {
return request.auth != null;
}
function requesterId() {
return request.auth.uid;
}
match /gardens/{userId}/{allPaths=**} {
allow read;
allow write: if request.auth != null && request.auth.uid == userId;
}
function isValidTrailAccess(userId) {
return isSignedIn() && isOwner(userId)
&& firestore.get(/databases/(default)/documents/users/$(requesterId())).data.superfan == true;
}
match /trails/{userId}/{singlePath} {
// Only superfans (members) can upload and see trails
allow read: if isValidTrailAccess(userId);
allow create: if isValidTrailAccess(userId);
allow delete: if isValidTrailAccess(userId);
// Updates are NOT allowed
}
}
}