mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-11-08 00:54:33 +01:00
Update auth settings endpoint to return updated flag and show whether updates were made in client toast
This commit is contained in:
parent
cf00650c6d
commit
341a0452da
@ -202,7 +202,7 @@ export default {
|
|||||||
this.$toast.error('Mobile Redirect URIs: Asterisk (*) must be the only entry if used')
|
this.$toast.error('Mobile Redirect URIs: Asterisk (*) must be the only entry if used')
|
||||||
isValid = false
|
isValid = false
|
||||||
} else {
|
} else {
|
||||||
uris.forEach(uri => {
|
uris.forEach((uri) => {
|
||||||
if (uri !== '*' && !isValidRedirectURI(uri)) {
|
if (uri !== '*' && !isValidRedirectURI(uri)) {
|
||||||
this.$toast.error(`Mobile Redirect URIs: Invalid URI ${uri}`)
|
this.$toast.error(`Mobile Redirect URIs: Invalid URI ${uri}`)
|
||||||
isValid = false
|
isValid = false
|
||||||
@ -230,7 +230,11 @@ export default {
|
|||||||
.$patch('/api/auth-settings', this.newAuthSettings)
|
.$patch('/api/auth-settings', this.newAuthSettings)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
this.$store.commit('setServerSettings', data.serverSettings)
|
this.$store.commit('setServerSettings', data.serverSettings)
|
||||||
this.$toast.success('Server settings updated')
|
if (data.updated) {
|
||||||
|
this.$toast.success('Server settings updated')
|
||||||
|
} else {
|
||||||
|
this.$toast.info(this.$strings.MessageNoUpdatesWereNecessary)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Failed to update server settings', error)
|
console.error('Failed to update server settings', error)
|
||||||
|
@ -631,21 +631,25 @@ class MiscController {
|
|||||||
}
|
}
|
||||||
} else if (key === 'authOpenIDMobileRedirectURIs') {
|
} else if (key === 'authOpenIDMobileRedirectURIs') {
|
||||||
function isValidRedirectURI(uri) {
|
function isValidRedirectURI(uri) {
|
||||||
const pattern = new RegExp('^\\w+://[\\w.-]+$', 'i');
|
if (typeof uri !== 'string') return false
|
||||||
return pattern.test(uri);
|
const pattern = new RegExp('^\\w+://[\\w.-]+$', 'i')
|
||||||
|
return pattern.test(uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
const uris = settingsUpdate[key]
|
const uris = settingsUpdate[key]
|
||||||
if (!Array.isArray(uris) ||
|
if (!Array.isArray(uris) ||
|
||||||
(uris.includes('*') && uris.length > 1) ||
|
(uris.includes('*') && uris.length > 1) ||
|
||||||
uris.some(uri => uri !== '*' && !isValidRedirectURI(uri))) {
|
uris.some(uri => uri !== '*' && !isValidRedirectURI(uri))) {
|
||||||
Logger.warn(`[MiscController] Invalid value for authOpenIDMobileRedirectURIs`)
|
Logger.warn(`[MiscController] Invalid value for authOpenIDMobileRedirectURIs`)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the URIs
|
// Update the URIs
|
||||||
Database.serverSettings[key] = uris
|
if (Database.serverSettings[key].some(uri => !uris.includes(uri)) || uris.some(uri => !Database.serverSettings[key].includes(uri))) {
|
||||||
hasUpdates = true
|
Logger.debug(`[MiscController] Updating auth settings key "${key}" from "${Database.serverSettings[key]}" to "${uris}"`)
|
||||||
|
Database.serverSettings[key] = uris
|
||||||
|
hasUpdates = true
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const updatedValueType = typeof settingsUpdate[key]
|
const updatedValueType = typeof settingsUpdate[key]
|
||||||
if (['authOpenIDAutoLaunch', 'authOpenIDAutoRegister'].includes(key)) {
|
if (['authOpenIDAutoLaunch', 'authOpenIDAutoRegister'].includes(key)) {
|
||||||
@ -688,6 +692,7 @@ class MiscController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
|
updated: hasUpdates,
|
||||||
serverSettings: Database.serverSettings.toJSONForBrowser()
|
serverSettings: Database.serverSettings.toJSONForBrowser()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user