2022-01-05 17:42:43 +00:00
|
|
|
rules_version = '2';
|
|
|
|
|
2022-01-24 06:45:46 +00:00
|
|
|
// To deploy: `firebase deploy --only firestore:rules`
|
2022-01-05 17:42:43 +00:00
|
|
|
service cloud.firestore {
|
|
|
|
match /databases/{database}/documents {
|
|
|
|
|
2022-01-24 06:45:46 +00:00
|
|
|
function isAdmin() {
|
2022-03-02 00:31:03 +00:00
|
|
|
return request.auth.uid == 'OTd2JFY7LOdvQg2ZQGYLUqrXAiD2' // Austin
|
|
|
|
|| request.auth.uid == 'czxKSN1Z03Mzu7UqIio3ppM0eDt2' // David
|
|
|
|
}
|
|
|
|
|
|
|
|
function isAuthed() {
|
|
|
|
return request.auth != null
|
2022-01-24 06:45:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-05 17:42:43 +00:00
|
|
|
match /users/{userId} {
|
2022-03-02 00:31:03 +00:00
|
|
|
allow read: if isAuthed();
|
2022-02-18 01:16:58 +00:00
|
|
|
allow update: if resource.data.id == request.auth.uid
|
|
|
|
&& request.resource.data.diff(resource.data).affectedKeys()
|
|
|
|
.hasOnly(['bio', 'bannerUrl', 'website', 'twitterHandle', 'discordHandle']);
|
2022-01-19 03:50:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
match /private-users/{userId} {
|
2022-01-26 21:03:45 +00:00
|
|
|
allow read: if resource.data.id == request.auth.uid || isAdmin();
|
2022-01-05 17:42:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
match /contracts/{contractId} {
|
2022-03-02 00:31:03 +00:00
|
|
|
allow read: if isAuthed();
|
2022-01-26 23:45:05 +00:00
|
|
|
allow update: if request.resource.data.diff(resource.data).affectedKeys()
|
2022-02-21 04:04:00 +00:00
|
|
|
.hasOnly(['description', 'closeTime', 'tags', 'lowercaseTags']);
|
2022-02-09 18:58:33 +00:00
|
|
|
allow update: if isAdmin();
|
2022-01-06 03:04:10 +00:00
|
|
|
allow delete: if resource.data.creatorId == request.auth.uid;
|
2022-01-05 17:42:43 +00:00
|
|
|
}
|
|
|
|
|
2022-01-05 17:47:39 +00:00
|
|
|
match /{somePath=**}/bets/{betId} {
|
2022-03-02 00:31:03 +00:00
|
|
|
allow read: if isAuthed();
|
2022-01-05 17:47:39 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 23:00:19 +00:00
|
|
|
match /{somePath=**}/comments/{commentId} {
|
2022-03-02 00:31:03 +00:00
|
|
|
allow read: if isAuthed();
|
2022-01-05 17:42:43 +00:00
|
|
|
allow create: if request.auth != null;
|
|
|
|
}
|
|
|
|
|
2022-02-17 23:00:19 +00:00
|
|
|
match /{somePath=**}/answers/{answerId} {
|
2022-03-02 00:31:03 +00:00
|
|
|
allow read: if isAuthed();
|
2022-01-05 22:52:54 +00:00
|
|
|
}
|
|
|
|
|
2022-01-21 23:21:46 +00:00
|
|
|
match /folds/{foldId} {
|
2022-03-02 00:31:03 +00:00
|
|
|
allow read: if isAuthed();
|
2022-01-26 20:56:15 +00:00
|
|
|
allow update, delete: if request.auth.uid == resource.data.curatorId;
|
2022-01-21 23:21:46 +00:00
|
|
|
}
|
2022-01-26 20:03:32 +00:00
|
|
|
|
2022-02-04 00:13:04 +00:00
|
|
|
match /{somePath=**}/followers/{userId} {
|
2022-03-02 00:31:03 +00:00
|
|
|
allow read: if isAuthed();
|
2022-02-17 23:00:19 +00:00
|
|
|
allow write: if request.auth.uid == userId;
|
2022-02-04 00:13:04 +00:00
|
|
|
}
|
2022-01-05 17:42:43 +00:00
|
|
|
}
|
|
|
|
}
|