-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
160 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { FirestoreQueryConstraint, where } from "@dereekb/firebase"; | ||
|
||
export function publishedGuestbookEntries(published = true): FirestoreQueryConstraint { | ||
export function publishedGuestbook(published = true): FirestoreQueryConstraint { | ||
return where('published', '==', published); | ||
} | ||
|
||
export function publishedGuestbookEntry(published = true): FirestoreQueryConstraint { | ||
return where('published', '==', published); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...src/app/modules/demo/modules/shared/modules/guestbook/store/guestbook.collection.store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { AbstractDbxFirebaseCollectionStore } from "@dereekb/dbx-firebase"; | ||
import { DemoFirestoreCollections, Guestbook, GuestbookDocument } from "@dereekb/demo-firebase"; | ||
import { DemoFirestoreCollections, Guestbook, GuestbookDocument, publishedGuestbook } from "@dereekb/demo-firebase"; | ||
|
||
@Injectable() | ||
export class GuestbookCollectionStore extends AbstractDbxFirebaseCollectionStore<Guestbook, GuestbookDocument> { | ||
|
||
constructor(collections: DemoFirestoreCollections) { | ||
super({ firestoreCollection: collections.guestbookFirestoreCollection }); | ||
this.setConstraints(publishedGuestbook()); // todo: replace with filter | ||
} | ||
|
||
} |
3 changes: 2 additions & 1 deletion
3
...p/modules/demo/modules/shared/modules/guestbook/store/guestbook.entry.collection.store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...app/modules/demo/modules/shared/modules/guestbook/store/guestbook.entry.document.store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,31 @@ | ||
rules_version = '2'; | ||
service cloud.firestore { | ||
match /databases/{database}/documents { | ||
match /{document=**} { | ||
allow read, write: if true; | ||
|
||
match /profile/{profile} { | ||
allow read: if resourceIsOwnedByAuthUserId(); | ||
} | ||
|
||
match /guestbook/{guestbook} { | ||
allow read: if resourceIsPublished(); | ||
|
||
match /entry/{entry} { | ||
|
||
// Can read any entry that is owned or published. | ||
allow get: if resourceIsPublished() || resourceIsOwnedByAuthUserId(); | ||
|
||
// Can only query if the guestbook entry is published. | ||
allow list: if resourceIsPublished(); | ||
} | ||
} | ||
|
||
function resourceIsPublished() { | ||
return (resource.data.published != false); | ||
} | ||
|
||
function resourceIsOwnedByAuthUserId() { | ||
return (resource.id == request.auth.uid); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters