Skip to content

Commit

Permalink
feat(homebrew): Updated homebrew db structure
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbenton committed Feb 20, 2024
1 parent 4753144 commit 1c04c7e
Show file tree
Hide file tree
Showing 64 changed files with 2,867 additions and 1,322 deletions.
47 changes: 32 additions & 15 deletions firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,40 @@ service cloud.firestore {
}
}
}
match /homebrew/{homebrewId} {
allow read: if request.auth.uid != null;
allow create: if request.auth.uid != null;
allow write: if request.auth.uid in resource.data.uids;

function checkIsHomebrewOwner() {
let homebrew = get(/databases/$(database)/documents/homebrew/$(homebrewId)).data;
return request.auth.uid in homebrew.uids;
match /homebrew/homebrew {
function checkIsHomebrewOwner(homebrewId) {
let homebrew = get(/databases/$(database)/documents/homebrew/homebrew/collections/$(homebrewId)).data;
return request.auth.uid in homebrew.editors;
}

match /rules/rules {
allow read: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner();

match /collections/{homebrewId} {
allow read: if request.auth.uid != null;
allow create: if request.auth.uid != null;
allow write: if request.auth.uid in resource.data.editors;
}

match /stats/{statId} {
allow read: if request.auth.uid != null;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}
match /oracles/oracles {
allow read: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner();

match /condition_meters/{conditionMeterId} {
allow read: if request.auth.uid != null;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}

match /impacts/{impactCategoryId} {
allow read: if request.auth.uid != null;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}

match /legacy_tracks/{legacyTrackId} {
allow read: if request.auth.uid != null;
allow create: if request.auth.uid != null;
allow write: if checkIsHomebrewOwner(resource.data.collectionId);
}
}
match /users/{userId} {
Expand Down
Loading

0 comments on commit 1c04c7e

Please sign in to comment.