Skip to content

Commit d429bea

Browse files
authored
Update firebase_rules.json (#147)
1 parent ea5cffd commit d429bea

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

my-app/firebase_rules.json

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,48 @@
33
// Courses and Metadata
44
"courses": {
55
".read": true,
6-
".write": "auth != null && auth.uid === 'adminuid'"
6+
".write": "auth != null && (auth.uid === '6qKa992eL4fRkGKzp3OG5Sjjk983' || auth.uid === 'wa9HoCfWe2Vpw6J7oiq5oCxNYz52')"
77
},
88
"metadata": {
99
".read": true,
10-
".write": "auth != null && auth.uid === 'adminuid'"
10+
".write": "auth != null && (auth.uid === '6qKa992eL4fRkGKzp3OG5Sjjk983' || auth.uid === 'wa9HoCfWe2Vpw6J7oiq5oCxNYz52')"
1111
},
1212
"departments": {
1313
".read": true,
14-
".write": "auth != null && auth.uid === 'adminuid'"
14+
".write": "auth != null && (auth.uid === '6qKa992eL4fRkGKzp3OG5Sjjk983' || auth.uid === 'wa9HoCfWe2Vpw6J7oiq5oCxNYz52')"
1515
},
1616
"locations": {
1717
".read": true,
18-
".write": "auth != null && auth.uid === 'adminuid'"
18+
".write": "auth != null && (auth.uid === '6qKa992eL4fRkGKzp3OG5Sjjk983' || auth.uid === 'wa9HoCfWe2Vpw6J7oiq5oCxNYz52')"
1919
},
2020

2121
// Reviews and Comments
2222
"reviews": {
2323
".read": true,
2424
"$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()",
2832

29-
// Allow anyone to write a comment
33+
// Allow any signed-in user to write comments under the review
3034
"comments": {
31-
".read": true,
35+
".write": "auth != null",
3236
"$commentId": {
33-
".write": "auth != null",
34-
".validate": "newData.hasChildren(['userName', 'text', 'timestamp']) &&
35-
newData.child('userName').isString() &&
37+
".validate": "newData.hasChildren(['text', 'userName', 'timestamp']) &&
3638
newData.child('text').isString() &&
39+
newData.child('userName').isString() &&
3740
newData.child('timestamp').isNumber()"
3841
}
3942
}
4043
}
4144
}
4245
},
4346

44-
// Users
47+
// User-specific Data
4548
"users": {
4649
"$userID": {
4750
".read": "auth != null && auth.uid === $userID",

0 commit comments

Comments
 (0)