From 8442a629fbc7b16b63cf2c7fdfa11866f03d1354 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sun, 16 Jan 2022 11:17:09 -0600 Subject: [PATCH] Fix:Get libraries endpoint return only libraries accessible to user --- server/controllers/LibraryController.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/controllers/LibraryController.js b/server/controllers/LibraryController.js index 3c3ebf05..e6415bee 100644 --- a/server/controllers/LibraryController.js +++ b/server/controllers/LibraryController.js @@ -29,6 +29,11 @@ class LibraryController { } findAll(req, res) { + var librariesAccessible = req.user.librariesAccessible || [] + if (librariesAccessible && librariesAccessible.length) { + return res.json(this.db.libraries.filter(lib => librariesAccessible.includes(lib.id)).map(lib => lib.toJSON())) + } + res.json(this.db.libraries.map(lib => lib.toJSON())) }