From 6d12bcb0632da32b378691938d7c8b7ad2cdffe1 Mon Sep 17 00:00:00 2001 From: Thaum Rystra Date: Thu, 28 May 2020 13:00:03 +0200 Subject: [PATCH] Public libraries no longer require login to view --- app/imports/server/publications/library.js | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/imports/server/publications/library.js b/app/imports/server/publications/library.js index 0a03aa95..dd18a826 100644 --- a/app/imports/server/publications/library.js +++ b/app/imports/server/publications/library.js @@ -40,16 +40,23 @@ let libraryIdSchema = new SimpleSchema({ Meteor.publish('library', function(libraryId){ libraryIdSchema.validate({libraryId}); this.autorun(function (){ - if (!this.userId) return []; - let libraryCursor = Libraries.find({ - _id: libraryId, - $or: [ - {owner: this.userId}, - {writers: this.userId}, - {readers: this.userId}, - {public: true}, - ], - }); + let libraryCursor + if (this.userId) { + libraryCursor = Libraries.find({ + _id: libraryId, + $or: [ + {owner: this.userId}, + {writers: this.userId}, + {readers: this.userId}, + {public: true}, + ], + }); + } else { + libraryCursor = Libraries.find({ + _id: libraryId, + public: true, + }); + } if (!libraryCursor.count()) return this.ready(); return [ libraryCursor,