More error handling around config saving
This commit is contained in:
parent
2afb6ffe2d
commit
3fbd762979
|
@ -92,6 +92,15 @@
|
|||
const providers = { google, oidc }
|
||||
|
||||
// Create a flag so that it will only try to save completed forms
|
||||
|
||||
$: trySaveGoogle =
|
||||
providers.google?.config.clientID ||
|
||||
providers.google?.config.clientSecret ||
|
||||
providers.google?.config.callbackURL
|
||||
$: trySaveOidc =
|
||||
providers.oidc?.config?.configs[0].configUrl ||
|
||||
providers.oidc?.config?.configs[0].clientID ||
|
||||
providers.oidc?.config?.configs[0].clientSecret
|
||||
$: googleComplete =
|
||||
providers.google?.config.clientID &&
|
||||
providers.google?.config.clientSecret &&
|
||||
|
@ -130,23 +139,27 @@
|
|||
element.config.configs.forEach(config => {
|
||||
!config.uuid && (config.uuid = uuid())
|
||||
})
|
||||
if (oidcComplete) {
|
||||
calls.push(api.post(`/api/admin/configs`, element))
|
||||
completed.push(ConfigTypes.OIDC)
|
||||
} else {
|
||||
if (trySaveOidc) {
|
||||
if (!oidcComplete) {
|
||||
notifications.error(
|
||||
`Please fill in all required ${ConfigTypes.OIDC} fields`
|
||||
)
|
||||
} else {
|
||||
calls.push(api.post(`/api/admin/configs`, element))
|
||||
completed.push(ConfigTypes.OIDC)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (element.type === ConfigTypes.Google) {
|
||||
if (googleComplete) {
|
||||
calls.push(api.post(`/api/admin/configs`, element))
|
||||
completed.push(ConfigTypes.OIDC)
|
||||
} else {
|
||||
if (trySaveGoogle) {
|
||||
if (!googleComplete) {
|
||||
notifications.error(
|
||||
`Please fill in all required ${ConfigTypes.Google} fields`
|
||||
)
|
||||
} else {
|
||||
calls.push(api.post(`/api/admin/configs`, element))
|
||||
completed.push(ConfigTypes.Google)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -167,7 +180,7 @@
|
|||
notifications.success(`Settings saved.`)
|
||||
})
|
||||
.catch(err => {
|
||||
notifications.error(`Failed to update OAuth settings. ${err}`)
|
||||
notifications.error(`Failed to update auth settings. ${err}`)
|
||||
throw new Error(err.message)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ export function createOrganisationStore() {
|
|||
async function init() {
|
||||
const res = await api.get(`/api/admin/configs/public`)
|
||||
const json = await res.json()
|
||||
console.log(json)
|
||||
|
||||
if (json.status === 400) {
|
||||
set(DEFAULT_CONFIG)
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue