|
3 | 3 | // Courses and Metadata |
4 | 4 | "courses": { |
5 | 5 | ".read": true, |
6 | | - ".write": "auth != null && auth.uid === 'adminuid'" |
| 6 | + ".write": "auth != null && (auth.uid === '6qKa992eL4fRkGKzp3OG5Sjjk983' || auth.uid === 'wa9HoCfWe2Vpw6J7oiq5oCxNYz52')" |
7 | 7 | }, |
8 | 8 | "metadata": { |
9 | 9 | ".read": true, |
10 | | - ".write": "auth != null && auth.uid === 'adminuid'" |
| 10 | + ".write": "auth != null && (auth.uid === '6qKa992eL4fRkGKzp3OG5Sjjk983' || auth.uid === 'wa9HoCfWe2Vpw6J7oiq5oCxNYz52')" |
11 | 11 | }, |
12 | 12 | "departments": { |
13 | 13 | ".read": true, |
14 | | - ".write": "auth != null && auth.uid === 'adminuid'" |
| 14 | + ".write": "auth != null && (auth.uid === '6qKa992eL4fRkGKzp3OG5Sjjk983' || auth.uid === 'wa9HoCfWe2Vpw6J7oiq5oCxNYz52')" |
15 | 15 | }, |
16 | 16 | "locations": { |
17 | 17 | ".read": true, |
18 | | - ".write": "auth != null && auth.uid === 'adminuid'" |
| 18 | + ".write": "auth != null && (auth.uid === '6qKa992eL4fRkGKzp3OG5Sjjk983' || auth.uid === 'wa9HoCfWe2Vpw6J7oiq5oCxNYz52')" |
19 | 19 | }, |
20 | 20 |
|
21 | 21 | // Reviews and Comments |
22 | 22 | "reviews": { |
23 | 23 | ".read": true, |
24 | 24 | "$courseCode": { |
25 | | - "$userID": { |
26 | | - // Only the review owner can write the main review fields (not including comments) |
27 | | - ".write": "auth != null && (auth.uid === $userID)", |
| 25 | + "$reviewUserID": { |
| 26 | + // Only the original author can write the main review |
| 27 | + ".write": "auth != null && (auth.uid === $reviewUserID || data.child('uid').val() === auth.uid || !data.exists())", |
| 28 | + ".validate": "newData.hasChildren(['text', 'timestamp']) && |
| 29 | + newData.child('text').isString() && |
| 30 | + newData.child('text').val().length <= 2501 && |
| 31 | + newData.child('timestamp').isNumber()", |
28 | 32 |
|
29 | | - // Allow anyone to write a comment |
| 33 | + // Allow any signed-in user to write comments under the review |
30 | 34 | "comments": { |
31 | | - ".read": true, |
| 35 | + ".write": "auth != null", |
32 | 36 | "$commentId": { |
33 | | - ".write": "auth != null", |
34 | | - ".validate": "newData.hasChildren(['userName', 'text', 'timestamp']) && |
35 | | - newData.child('userName').isString() && |
| 37 | + ".validate": "newData.hasChildren(['text', 'userName', 'timestamp']) && |
36 | 38 | newData.child('text').isString() && |
| 39 | + newData.child('userName').isString() && |
37 | 40 | newData.child('timestamp').isNumber()" |
38 | 41 | } |
39 | 42 | } |
40 | 43 | } |
41 | 44 | } |
42 | 45 | }, |
43 | 46 |
|
44 | | - // Users |
| 47 | + // User-specific Data |
45 | 48 | "users": { |
46 | 49 | "$userID": { |
47 | 50 | ".read": "auth != null && auth.uid === $userID", |
|
0 commit comments