mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-11-24 01:14:11 +01:00
Update settings PATCH endpoint to only accept a fixed set of general settings (auth settings must go through the auth-settings endpoint)
This commit is contained in:
1 parent
42bf9512b0
commit
3d62a103ae
2 files changed
+38
-21
No files matched your search
@@ -10,6 +10,7 @@ const Watcher = require('../Watcher')
|
||||
const libraryItemFilters = require('../utils/queries/libraryItemFilters')
|
||||
const cron = require('../libs/nodeCron')
|
||||
const { isObject, getTitleIgnorePrefix } = require('../utils/index')
|
||||
const ServerSettings = require('../objects/settings/ServerSettings')
|
||||
const { sanitizeFilename } = require('../utils/fileUtils')
|
||||
|
||||
const TaskManager = require('../managers/TaskManager')
|
||||
@@ -142,16 +143,23 @@ class MiscController {
|
||||
Logger.warn('Cannot disable iframe when ALLOW_IFRAME is enabled in environment')
|
||||
return res.status(400).send('Cannot disable iframe when ALLOW_IFRAME is enabled in environment')
|
||||
}
|
||||
if (settingsUpdate.allowedOrigins && !Array.isArray(settingsUpdate.allowedOrigins)) {
|
||||
const filteredUpdate = {}
|
||||
for (const key in settingsUpdate) {
|
||||
if (ServerSettings.patchableSettingsKeys.has(key)) {
|
||||
filteredUpdate[key] = settingsUpdate[key]
|
||||
}
|
||||
}
|
||||
|
||||
if (filteredUpdate.allowedOrigins && !Array.isArray(filteredUpdate.allowedOrigins)) {
|
||||
return res.status(400).send('allowedOrigins must be an array')
|
||||
}
|
||||
|
||||
const madeUpdates = Database.serverSettings.update(settingsUpdate)
|
||||
const madeUpdates = Database.serverSettings.update(filteredUpdate)
|
||||
if (madeUpdates) {
|
||||
await Database.updateServerSettings()
|
||||
|
||||
// If backup schedule is updated - update backup manager
|
||||
if (settingsUpdate.backupSchedule !== undefined) {
|
||||
if (filteredUpdate.backupSchedule !== undefined) {
|
||||
this.backupManager.updateCronSchedule()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user