mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +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')
 | 
			
		||||
        isValid = false
 | 
			
		||||
      } else {
 | 
			
		||||
        uris.forEach(uri => {
 | 
			
		||||
        uris.forEach((uri) => {
 | 
			
		||||
          if (uri !== '*' && !isValidRedirectURI(uri)) {
 | 
			
		||||
            this.$toast.error(`Mobile Redirect URIs: Invalid URI ${uri}`)
 | 
			
		||||
            isValid = false
 | 
			
		||||
@ -230,7 +230,11 @@ export default {
 | 
			
		||||
        .$patch('/api/auth-settings', this.newAuthSettings)
 | 
			
		||||
        .then((data) => {
 | 
			
		||||
          this.$store.commit('setServerSettings', data.serverSettings)
 | 
			
		||||
          if (data.updated) {
 | 
			
		||||
            this.$toast.success('Server settings updated')
 | 
			
		||||
          } else {
 | 
			
		||||
            this.$toast.info(this.$strings.MessageNoUpdatesWereNecessary)
 | 
			
		||||
          }
 | 
			
		||||
        })
 | 
			
		||||
        .catch((error) => {
 | 
			
		||||
          console.error('Failed to update server settings', error)
 | 
			
		||||
 | 
			
		||||
@ -631,8 +631,9 @@ class MiscController {
 | 
			
		||||
        }
 | 
			
		||||
      } else if (key === 'authOpenIDMobileRedirectURIs') {
 | 
			
		||||
        function isValidRedirectURI(uri) {
 | 
			
		||||
          const pattern = new RegExp('^\\w+://[\\w.-]+$', 'i');
 | 
			
		||||
          return pattern.test(uri);
 | 
			
		||||
          if (typeof uri !== 'string') return false
 | 
			
		||||
          const pattern = new RegExp('^\\w+://[\\w.-]+$', 'i')
 | 
			
		||||
          return pattern.test(uri)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const uris = settingsUpdate[key]
 | 
			
		||||
@ -644,8 +645,11 @@ class MiscController {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Update the URIs
 | 
			
		||||
        if (Database.serverSettings[key].some(uri => !uris.includes(uri)) || uris.some(uri => !Database.serverSettings[key].includes(uri))) {
 | 
			
		||||
          Logger.debug(`[MiscController] Updating auth settings key "${key}" from "${Database.serverSettings[key]}" to "${uris}"`)
 | 
			
		||||
          Database.serverSettings[key] = uris
 | 
			
		||||
          hasUpdates = true
 | 
			
		||||
        }
 | 
			
		||||
      } else {
 | 
			
		||||
        const updatedValueType = typeof settingsUpdate[key]
 | 
			
		||||
        if (['authOpenIDAutoLaunch', 'authOpenIDAutoRegister'].includes(key)) {
 | 
			
		||||
@ -688,6 +692,7 @@ class MiscController {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    res.json({
 | 
			
		||||
      updated: hasUpdates,
 | 
			
		||||
      serverSettings: Database.serverSettings.toJSONForBrowser()
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user