Fix config form saving bugs
This commit is contained in:
parent
67fbf73bdd
commit
283698f8c5
|
@ -64,8 +64,20 @@
|
||||||
|
|
||||||
let fileinput
|
let fileinput
|
||||||
let image
|
let image
|
||||||
|
|
||||||
let google
|
let google
|
||||||
let oidc
|
let oidc
|
||||||
|
const providers = { google, oidc }
|
||||||
|
|
||||||
|
// Create a flag so that it will only try to save completed forms
|
||||||
|
$: googleComplete =
|
||||||
|
providers.google?.config.clientID &&
|
||||||
|
providers.google?.config.clientSecret &&
|
||||||
|
providers.google?.config.callbackURL
|
||||||
|
$: oidcComplete =
|
||||||
|
providers.oidc?.config.configs[0].configUrl &&
|
||||||
|
providers.oidc?.config.configs[0].clientID &&
|
||||||
|
providers.oidc?.config.configs[0].clientSecret
|
||||||
|
|
||||||
async function uploadLogo(file) {
|
async function uploadLogo(file) {
|
||||||
let data = new FormData()
|
let data = new FormData()
|
||||||
|
@ -85,20 +97,21 @@
|
||||||
iconDropdownOptions.unshift({ label: fileName, value: fileName })
|
iconDropdownOptions.unshift({ label: fileName, value: fileName })
|
||||||
}
|
}
|
||||||
|
|
||||||
const providers = { google, oidc }
|
|
||||||
|
|
||||||
async function save(docs) {
|
async function save(docs) {
|
||||||
// only if the user has provided an image, upload it.
|
// only if the user has provided an image, upload it.
|
||||||
image && uploadLogo(image)
|
image && uploadLogo(image)
|
||||||
let calls = []
|
let calls = []
|
||||||
docs.forEach(element => {
|
docs.forEach(element => {
|
||||||
//Add a UUID here so each config is distinguishable when it arrives at the login page.
|
if (element.type === ConfigTypes.OIDC) {
|
||||||
if (element.type === "oidc") {
|
//Add a UUID here so each config is distinguishable when it arrives at the login page.
|
||||||
element.config.configs.forEach(config => {
|
element.config.configs.forEach(config => {
|
||||||
config.uuid = uuid()
|
!config.uuid && (config.uuid = uuid())
|
||||||
})
|
})
|
||||||
|
oidcComplete && calls.push(api.post(`/api/admin/configs`, element))
|
||||||
|
}
|
||||||
|
if (element.type === ConfigTypes.Google) {
|
||||||
|
googleComplete && calls.push(api.post(`/api/admin/configs`, element))
|
||||||
}
|
}
|
||||||
calls.push(api.post(`/api/admin/configs`, element))
|
|
||||||
})
|
})
|
||||||
Promise.all(calls)
|
Promise.all(calls)
|
||||||
.then(responses => {
|
.then(responses => {
|
||||||
|
|
|
@ -226,7 +226,7 @@ exports.configChecklist = async function (ctx) {
|
||||||
apps: appDbNames.length,
|
apps: appDbNames.length,
|
||||||
smtp: !!smtpConfig,
|
smtp: !!smtpConfig,
|
||||||
adminUser,
|
adminUser,
|
||||||
sso: !!googleConfig || !!oidcConfig
|
sso: !!googleConfig || !!oidcConfig,
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
ctx.throw(err.status, err)
|
ctx.throw(err.status, err)
|
||||||
|
|
|
@ -49,8 +49,8 @@ function oidcValidation() {
|
||||||
clientID: Joi.string().required(),
|
clientID: Joi.string().required(),
|
||||||
clientSecret: Joi.string().required(),
|
clientSecret: Joi.string().required(),
|
||||||
configUrl: Joi.string().required(),
|
configUrl: Joi.string().required(),
|
||||||
logo: Joi.string().optional(),
|
logo: Joi.string().allow("", null),
|
||||||
name: Joi.string().optional(),
|
name: Joi.string().allow("", null),
|
||||||
uuid: Joi.string().required(),
|
uuid: Joi.string().required(),
|
||||||
})
|
})
|
||||||
).required(true)
|
).required(true)
|
||||||
|
|
Loading…
Reference in New Issue