-
Notifications
You must be signed in to change notification settings - Fork 1
/
firestore.rules
53 lines (53 loc) · 2.07 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
service cloud.firestore {
match /databases/{database}/documents {
function canCreate() {
return request.resource.data.owner == request.auth.token.email;
}
function canCreateTask() {
return request.auth.token.email in request.resource.data.owner;
}
function canReadWriteDelete() {
return request.auth.token.email in resource.data.owner || request.auth.token.email == resource.data.owner;
}
function canOperateOnEmailIdDocs(userEmail) {
return request.auth.token.email == userEmail;
}
function getGroupMembers(group){
return get(/databases/$(database)/documents/samwise-groups/$(group)).data.members
}
match /samwise-order-manager/{userEmail} {
allow create, read, write, delete: if canOperateOnEmailIdDocs(userEmail)
}
match /samwise-settings/{userEmail} {
allow create, read, write, delete: if canOperateOnEmailIdDocs(userEmail)
}
match /samwise-banner-message/{userEmail} {
allow create, read, write, delete: if canOperateOnEmailIdDocs(userEmail)
}
match /samwise-tags/{tag} {
allow create: if canCreate()
allow read, write, delete: if canReadWriteDelete()
}
match /samwise-tasks/{task} {
allow create: if canCreateTask()
|| request.auth.token.email in getGroupMembers(request.resource.data.group);
allow read, write, delete: if canReadWriteDelete()
|| request.auth.token.email in getGroupMembers(resource.data.group);
}
match /samwise-subtasks/{task} {
allow create: if canCreate()
allow read, write, delete: if canReadWriteDelete()
}
match /samwise-groups/{group} {
allow create: if request.auth.uid != null
allow read, write, delete: if request.auth.token.email in resource.data.members
|| request.auth.token.email in resource.data.invitees
}
match /samwise-users/{user} {
allow create: if canOperateOnEmailIdDocs(user);
allow get: if canOperateOnEmailIdDocs(user)
|| request.auth.token.email.matches('.*@cornell[.]edu');
allow write, delete: if canOperateOnEmailIdDocs(user);
}
}
}