1
0
Fork 0
mirror of synced 2024-09-30 09:07:25 +13:00

Fix config form saving bugs

This commit is contained in:
Peter Clement 2021-07-13 21:46:50 +01:00
parent 67fbf73bdd
commit 283698f8c5
3 changed files with 22 additions and 9 deletions

View file

@ -64,8 +64,20 @@
let fileinput
let image
let google
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) {
let data = new FormData()
@ -85,20 +97,21 @@
iconDropdownOptions.unshift({ label: fileName, value: fileName })
}
const providers = { google, oidc }
async function save(docs) {
// only if the user has provided an image, upload it.
image && uploadLogo(image)
let calls = []
docs.forEach(element => {
//Add a UUID here so each config is distinguishable when it arrives at the login page.
if (element.type === "oidc") {
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 = 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)
.then(responses => {

View file

@ -226,7 +226,7 @@ exports.configChecklist = async function (ctx) {
apps: appDbNames.length,
smtp: !!smtpConfig,
adminUser,
sso: !!googleConfig || !!oidcConfig
sso: !!googleConfig || !!oidcConfig,
}
} catch (err) {
ctx.throw(err.status, err)

View file

@ -49,8 +49,8 @@ function oidcValidation() {
clientID: Joi.string().required(),
clientSecret: Joi.string().required(),
configUrl: Joi.string().required(),
logo: Joi.string().optional(),
name: Joi.string().optional(),
logo: Joi.string().allow("", null),
name: Joi.string().allow("", null),
uuid: Joi.string().required(),
})
).required(true)