mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-22 00:07:52 +01:00
Fix:Library controller middleware for user accessible libraries
This commit is contained in:
parent
156a4ed01d
commit
336fbedc75
@ -38,12 +38,6 @@ class LibraryController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async findOne(req, res) {
|
async findOne(req, res) {
|
||||||
var librariesAccessible = req.user.librariesAccessible || []
|
|
||||||
if (librariesAccessible && librariesAccessible.length && !librariesAccessible.includes(req.library.id)) {
|
|
||||||
Logger.warn(`[LibraryController] Library ${req.library.id} not accessible to user ${req.user.username}`)
|
|
||||||
return res.sendStatus(404)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (req.query.include && req.query.include === 'filterdata') {
|
if (req.query.include && req.query.include === 'filterdata') {
|
||||||
var books = this.db.audiobooks.filter(ab => ab.libraryId === req.library.id)
|
var books = this.db.audiobooks.filter(ab => ab.libraryId === req.library.id)
|
||||||
return res.json({
|
return res.json({
|
||||||
@ -424,6 +418,12 @@ class LibraryController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
middleware(req, res, next) {
|
middleware(req, res, next) {
|
||||||
|
var librariesAccessible = req.user.librariesAccessible || []
|
||||||
|
if (librariesAccessible && librariesAccessible.length && !librariesAccessible.includes(req.params.id)) {
|
||||||
|
Logger.warn(`[LibraryController] Library ${req.params.id} not accessible to user ${req.user.username}`)
|
||||||
|
return res.sendStatus(404)
|
||||||
|
}
|
||||||
|
|
||||||
var library = this.db.libraries.find(lib => lib.id === req.params.id)
|
var library = this.db.libraries.find(lib => lib.id === req.params.id)
|
||||||
if (!library) {
|
if (!library) {
|
||||||
return res.status(404).send('Library not found')
|
return res.status(404).send('Library not found')
|
||||||
|
Loading…
Reference in New Issue
Block a user