mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-18 13:52:02 +02:00
cleanup
This commit is contained in:
parent
3cd09eecba
commit
b77f7f2514
@ -297,14 +297,12 @@ class ApiController {
|
|||||||
return res.sendStatus(403)
|
return res.sendStatus(403)
|
||||||
}
|
}
|
||||||
let SSOUpdate = req.body
|
let SSOUpdate = req.body
|
||||||
Logger.debug("SSOUpdate=", SSOUpdate)
|
|
||||||
if (!SSOUpdate || !isObject(SSOUpdate)) {
|
if (!SSOUpdate || !isObject(SSOUpdate)) {
|
||||||
return res.status(500).send('Invalid settings update object')
|
return res.status(500).send('Invalid settings update object')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var madeUpdates = this.db.SSOSettings.update(SSOUpdate)
|
var madeUpdates = this.db.SSOSettings.update(SSOUpdate)
|
||||||
console.log("SSOUpdate", JSON.stringify(this.db.SSOSettings))
|
|
||||||
if (madeUpdates) {
|
if (madeUpdates) {
|
||||||
await this.db.updateEntity('settings', this.db.SSOSettings)
|
await this.db.updateEntity('settings', this.db.SSOSettings)
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ class SSOSettings {
|
|||||||
this.id = 'sso-settings'
|
this.id = 'sso-settings'
|
||||||
this.user = { ...settings.user }
|
this.user = { ...settings.user }
|
||||||
this.initOIDCSettings(settings);
|
this.initOIDCSettings(settings);
|
||||||
Logger.debug("[SSOSettings.constructor]", this.toJSON)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initOIDCSettings(settings) {
|
initOIDCSettings(settings) {
|
||||||
@ -75,31 +74,12 @@ class SSOSettings {
|
|||||||
const oldTmp = JSON.stringify(this.toJSON())
|
const oldTmp = JSON.stringify(this.toJSON())
|
||||||
const newTmp = JSON.stringify(payload) // deep copy "for free"
|
const newTmp = JSON.stringify(payload) // deep copy "for free"
|
||||||
const hasUpdates = difference(oldTmp, newTmp) !== ""; // Not very efficient, but ok for small objects
|
const hasUpdates = difference(oldTmp, newTmp) !== ""; // Not very efficient, but ok for small objects
|
||||||
Logger.debug(`SSOSettings hasUpdates=${hasUpdates}`)
|
|
||||||
if (!hasUpdates) return hasUpdates
|
if (!hasUpdates) return hasUpdates
|
||||||
|
|
||||||
payload = JSON.parse(newTmp)
|
payload = JSON.parse(newTmp)
|
||||||
this.oidc = payload.oidc
|
this.oidc = payload.oidc
|
||||||
this.user = payload.user
|
this.user = payload.user
|
||||||
return hasUpdates
|
return hasUpdates
|
||||||
Logger.debug("SSOSettings.update", payload, this)
|
|
||||||
for (const key in payload) {
|
|
||||||
Logger.debug(`key: ${key}: ${JSON.stringify(payload[key])}`)
|
|
||||||
if (isObject(payload[key])) {
|
|
||||||
for (const setting in payload[key]) {
|
|
||||||
if (!this[key] || this[key][setting] === payload[key][setting]) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
this[key][setting] = payload[key][setting]
|
|
||||||
hasUpdates = true
|
|
||||||
}
|
|
||||||
} else if (this[key] !== undefined && this[key] !== payload[key]) {
|
|
||||||
this[key] = payload[key]
|
|
||||||
hasUpdates = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Logger.debug("SSOSettings.update", hasUpdates, this)
|
|
||||||
return hasUpdates
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getNewUserPermissions() {
|
getNewUserPermissions() {
|
||||||
|
Loading…
Reference in New Issue
Block a user