|
5 | 5 | "v2": { |
6 | 6 | "announcement": { |
7 | 7 | ".write": false, |
8 | | - ".read": true |
| 8 | + ".read": "auth != null" |
9 | 9 | }, |
10 | 10 | "projects": { |
11 | 11 | ".write": false, |
12 | | - ".read": "auth != null", |
| 12 | + ".read": " |
| 13 | + // all users can query by status |
| 14 | + (auth != null && query.orderByChild == 'status' && query.equalTo == 'active') |
| 15 | + || |
| 16 | + // only team members can query by their own teamId |
| 17 | + (auth != null && query.orderByChild == 'teamId' && |
| 18 | + query.equalTo == root.child('/v2/users/'+auth.uid+'/teamId').val()) |
| 19 | + || |
| 20 | + // project managers can read all |
| 21 | + (auth.token.projectManager === true) |
| 22 | + ", |
13 | 23 | "$project_id": { |
14 | | - "status": { |
15 | | - ".write": "auth.token.projectManager === true" |
16 | | - }, |
17 | | - "isFeatured": { |
18 | | - ".write": "auth.token.projectManager === true" |
19 | | - } |
| 24 | + // project managers can read/write all attributes |
| 25 | + ".write": "auth.token.projectManager === true", |
| 26 | + ".read": " |
| 27 | + // all users can read all public projects |
| 28 | + (data.child('teamId').exists() == false) |
| 29 | + || |
| 30 | + // team members can read their projects |
| 31 | + (data.child('teamId').val() == root.child('/v2/users/'+auth.uid+'/teamId').val()) |
| 32 | + " |
20 | 33 | }, |
21 | 34 | ".indexOn": [ |
22 | | - "status", "isFeatured" |
23 | | - ] |
| 35 | + "status", "isFeatured", "teamId" |
| 36 | + ] |
24 | 37 | }, |
25 | 38 | "projectDrafts": { |
| 39 | + // only project managers can write projectDrafts |
26 | 40 | ".read": false, |
27 | 41 | ".write": "auth.token.projectManager === true", |
28 | 42 | ".indexOn": [ |
|
31 | 45 | }, |
32 | 46 | "groups": { |
33 | 47 | ".write": false, |
34 | | - ".read": true, |
| 48 | + ".read": "auth.token.projectManager === true", |
35 | 49 | "$project_id": { |
36 | | - ".indexOn": [ |
37 | | - "finishedCount", |
38 | | - "requiredCount" |
39 | | - ] |
40 | | - } |
| 50 | + ".read": " |
| 51 | + // everyone can read groups for public projects |
| 52 | + (root.child('/v2/projects/'+$project_id).hasChild('teamId') === false) |
| 53 | + || |
| 54 | + (root.child('/v2/projects/'+$project_id+'/teamId').val() == |
| 55 | + root.child('/v2/users/'+auth.uid+'/teamId').val()) |
| 56 | + " |
| 57 | + }, |
| 58 | + ".indexOn": [ |
| 59 | + "finishedCount", |
| 60 | + "requiredCount" |
| 61 | + ] |
41 | 62 | }, |
42 | 63 | "tasks": { |
43 | 64 | ".write": false, |
44 | | - ".read": true |
| 65 | + ".read": "auth.token.projectManager === true", |
| 66 | + "$project_id": { |
| 67 | + ".read": " |
| 68 | + // everyone can read groups for public projects |
| 69 | + (root.child('/v2/projects/'+$project_id).hasChild('teamId') === false) |
| 70 | + || |
| 71 | + (root.child('/v2/projects/'+$project_id+'/teamId').val() == |
| 72 | + root.child('/v2/users/'+auth.uid+'/teamId').val()) |
| 73 | + " |
| 74 | + }, |
| 75 | + }, |
| 76 | + "teams": { |
| 77 | + ".write": false, |
| 78 | + // project managers can read all attributes |
| 79 | + ".read": "auth.token.projectManager === true", |
| 80 | + "$teamId": { |
| 81 | + ".write": "auth.token.projectManager === true", |
| 82 | + "teamName": { |
| 83 | + // team members read teamName |
| 84 | + ".read": "(root.child('/v2/users/'+auth.uid+'/teamId').val() === $teamId)" |
| 85 | + //".read": "auth != null" |
| 86 | + }, |
| 87 | + ".indexOn": [ |
| 88 | + "teamName" |
| 89 | + ] |
| 90 | + } |
45 | 91 | }, |
46 | 92 | "results": { |
47 | 93 | ".write": false, |
48 | 94 | ".read": false, |
49 | 95 | "$project_id": { |
50 | 96 | "$group_id": { |
51 | 97 | "$uid": { |
52 | | - ".write": "$uid === auth.uid" |
| 98 | + ".write": " |
| 99 | + // everyone can write results for public projects |
| 100 | + (root.child('/v2/projects/'+$project_id).hasChild('teamId') === false && |
| 101 | + auth.uid == $uid |
| 102 | + ) |
| 103 | + || |
| 104 | + (root.child('/v2/projects/'+$project_id+'/teamId').val() == |
| 105 | + root.child('/v2/users/'+auth.uid+'/teamId').val() && |
| 106 | + auth.uid == $uid |
| 107 | + ) |
| 108 | + " |
53 | 109 | } |
54 | 110 | } |
55 | 111 | } |
56 | 112 | }, |
57 | 113 | "users": { |
58 | 114 | ".read": true, |
| 115 | + ".write": false, |
59 | 116 | "$uid": { |
60 | | - ".write": "auth != null && auth.uid == $uid" |
61 | | - }, |
62 | | - ".indexOn": [ |
63 | | - "created" |
64 | | - ] |
65 | | - } |
66 | | - }, |
67 | | - "groups": { |
68 | | - ".write": false, |
69 | | - ".read": true, |
70 | | - "$project_id": { |
71 | | - "$group_id": { |
72 | | - ".indexOn": [ |
73 | | - "distributedCount", |
74 | | - "completedCount" |
75 | | - ], |
76 | | - ".write": "auth != null", |
77 | | - "completedCount": { |
78 | | - ".write": "auth != null" |
| 117 | + "teamId": { |
| 118 | + ".write": false |
| 119 | + }, |
| 120 | + "$other": { |
| 121 | + ".write": "auth != null && auth.uid == $uid" |
79 | 122 | } |
80 | 123 | }, |
81 | 124 | ".indexOn": [ |
82 | | - "distributedCount", |
83 | | - "completedCount" |
| 125 | + "created", |
| 126 | + "teamId" |
84 | 127 | ] |
85 | 128 | } |
86 | 129 | }, |
87 | | - "imports": { |
88 | | - ".read": false, |
89 | | - ".write": true, |
90 | | - ".indexOn": [ |
91 | | - "complete" |
92 | | - ] |
93 | | - }, |
94 | | - "projects": { |
95 | | - ".write": false, |
96 | | - ".read": true |
97 | | - }, |
98 | | - "announcement": { |
99 | | - ".write": true, |
100 | | - ".read": true |
101 | | - }, |
102 | | - "results": { |
103 | | - ".write": false, |
104 | | - ".read": true, |
105 | | - "$task_id": { |
106 | | - "$user_id": { |
107 | | - ".write": "auth != null && auth.uid == $user_id" |
108 | | - } |
109 | | - } |
110 | | - }, |
| 130 | + // leaving this here, since version before v2 pull data from there |
111 | 131 | "users": { |
112 | 132 | "$uid": { |
113 | 133 | ".read": "auth != null && auth.uid == $uid", |
114 | 134 | ".write": "auth != null && auth.uid == $uid" |
115 | | - }, |
116 | | - ".read": true |
| 135 | + } |
117 | 136 | } |
118 | 137 | } |
119 | 138 | } |
0 commit comments