Better error handling around config saving

This commit is contained in:
Peter Clement 2021-07-16 10:51:58 +01:00
parent d13b2025d5
commit 87eea284ab
1 changed files with 36 additions and 20 deletions

View File

@ -123,18 +123,34 @@
// only if the user has provided an image, upload it.
image && uploadLogo(image)
let calls = []
let completed = []
docs.forEach(element => {
if (element.type === ConfigTypes.OIDC) {
//Add a UUID here so each config is distinguishable when it arrives at the login page.
element.config.configs.forEach(config => {
!config.uuid && (config.uuid = uuid())
})
oidcComplete && calls.push(api.post(`/api/admin/configs`, element))
if (oidcComplete) {
calls.push(api.post(`/api/admin/configs`, element))
completed.push(ConfigTypes.OIDC)
} else {
notifications.error(
`Please fill in all required ${ConfigTypes.OIDC} fields`
)
}
}
if (element.type === ConfigTypes.Google) {
googleComplete && calls.push(api.post(`/api/admin/configs`, element))
if (googleComplete) {
calls.push(api.post(`/api/admin/configs`, element))
completed.push(ConfigTypes.OIDC)
} else {
notifications.error(
`Please fill in all required ${ConfigTypes.Google} fields`
)
}
}
})
calls.length &&
Promise.all(calls)
.then(responses => {
return Promise.all(