forked from garv-shah/aporia-network
-
Notifications
You must be signed in to change notification settings - Fork 1
/
firestore.rules
71 lines (58 loc) · 1.96 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Function available for all collections
// Checks that request is coming from an authenticated user
function isSignedIn() {
return request.auth != null;
}
// Checks that the supplied userID is the same as the logged in one
function hasID(userID) {
return request.auth.uid == userID;
}
// Checks if user is admin
function isAdmin() {
return request.auth.uid in get(/databases/$(database)/documents/roles/admins).data.members;
}
// Checks if user is admin
function isCompany() {
return request.auth.uid in get(/databases/$(database)/documents/roles/companies).data.members;
}
match /global/subjects {
allow create, update, delete: if isAdmin();
allow read: if isSignedIn();
}
match /availability/{userID} {
allow create, update, delete: if (isSignedIn() && hasID(userID)) || isAdmin();
allow read: if isSignedIn();
}
match /availability/{userID}/slots/{slot} {
allow create, update, delete: if (isSignedIn() && hasID(userID)) || isAdmin();
allow read: if isSignedIn();
}
match /jobs/{job} {
allow create, update, delete: if (isSignedIn() && isCompany()) || isAdmin();
allow read: if isSignedIn();
}
match /postGroups/{group} {
allow create, update, delete: if isAdmin();
allow read: if isSignedIn();
}
match /posts/{post} {
allow create, update, delete: if isAdmin();
allow read: if isSignedIn();
}
match /publicProfile/{userID} {
allow create, update, delete: if isAdmin();
allow read: if isSignedIn();
}
match /roles/{role} {
allow create, update, delete: if isAdmin();
allow read: if isSignedIn();
}
match /userInfo/{userID} {
allow create, read: if isSignedIn();
allow update, delete: if (isSignedIn() && hasID(userID)) || isAdmin();
}
}
}