-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
95 lines (84 loc) · 3.3 KB
/
firestore.rules
File metadata and controls
95 lines (84 loc) · 3.3 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isAuthenticated() {
return request.auth != null;
}
function myRole() {
return get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role;
}
match /users/{userId} {
allow read: if isAuthenticated();
allow create, update: if isAuthenticated() && request.auth.uid == userId;
allow delete: if false;
}
match /companies/{companyId} {
allow read: if isAuthenticated();
allow create: if isAuthenticated()
&& myRole() == 'recruiter'
&& request.resource.data.ownerId == request.auth.uid;
allow update, delete: if isAuthenticated()
&& resource.data.ownerId == request.auth.uid;
}
match /posts/{postId} {
allow read: if isAuthenticated();
allow create: if isAuthenticated()
&& request.resource.data.authorId == request.auth.uid;
allow update: if isAuthenticated();
allow delete: if isAuthenticated()
&& resource.data.authorId == request.auth.uid;
match /likes/{likeId} {
allow read: if isAuthenticated();
allow create, delete: if isAuthenticated() && request.auth.uid == likeId;
allow update: if false;
}
match /comments/{commentId} {
allow read: if isAuthenticated();
allow create: if isAuthenticated();
allow update, delete: if false;
}
}
match /follows/{followId} {
allow read: if isAuthenticated();
allow create: if isAuthenticated()
&& myRole() == 'student'
&& request.resource.data.studentId == request.auth.uid;
allow delete: if isAuthenticated()
&& resource.data.studentId == request.auth.uid;
allow update: if false;
}
match /jobs/{jobId} {
allow read: if isAuthenticated();
allow create: if isAuthenticated()
&& myRole() == 'recruiter'
&& request.resource.data.companyId is string
&& exists(/databases/$(database)/documents/companies/$(request.resource.data.companyId))
&& get(/databases/$(database)/documents/companies/$(request.resource.data.companyId)).data.ownerId == request.auth.uid;
allow update, delete: if isAuthenticated()
&& myRole() == 'recruiter'
&& resource.data.companyId is string
&& exists(/databases/$(database)/documents/companies/$(resource.data.companyId))
&& get(/databases/$(database)/documents/companies/$(resource.data.companyId)).data.ownerId == request.auth.uid;
}
match /applications/{applicationId} {
allow read: if isAuthenticated();
allow create: if isAuthenticated()
&& myRole() == 'student'
&& request.resource.data.studentId == request.auth.uid;
allow update, delete: if false;
}
match /chats/{chatId} {
allow read: if isAuthenticated()
&& request.auth.uid in resource.data.participantIds;
allow create: if isAuthenticated()
&& request.auth.uid in request.resource.data.participantIds;
allow update: if isAuthenticated()
&& request.auth.uid in resource.data.participantIds;
match /messages/{messageId} {
allow read: if isAuthenticated();
allow create: if isAuthenticated();
allow update, delete: if isAuthenticated();
}
}
}
}