-
Notifications
You must be signed in to change notification settings - Fork 39
/
storage.rules
51 lines (41 loc) · 1.15 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /tanam-documents/{documentId}/{allPaths=**} {
allow read: if hasAnyRole();
allow write: if hasAnyRole();
}
match /tanam-users/{uid} {
match /{allPaths=**} {
allow read: if request.auth != null && request.auth.uid == uid;
}
match /profile.png {
allow read: if request.auth != null;
}
match /profile-picture-new {
allow create: if request.auth != null && request.auth.uid == uid;
}
match /new-profile-image {
allow create: if request.auth != null && request.auth.uid == uid;
}
}
}
function hasUserRole(role) {
return isSignedIn() && role == request.auth.token.tanamRole;
}
function hasAnyRole() {
return isSignedIn() && request.auth.token.tanamRole != null;
}
function isAtLeastAdmin() {
return hasUserRole("admin");
}
function isPublisher() {
return isAtLeastAdmin() || hasUserRole("publisher");
}
function isSignedIn() {
return request.auth != null;
}
function isSignedInAs(uid) {
return isSignedIn() && request.auth.uid == uid;
}
}