From bcfbca0f085aeb033efb464b23a4823c896d003c Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Fri, 9 Jul 2021 09:49:16 +0100 Subject: [PATCH] Add oidc icon and name to public api for login page --- .../src/api/controllers/admin/configs.js | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/worker/src/api/controllers/admin/configs.js b/packages/worker/src/api/controllers/admin/configs.js index d83be15667..8774dd488d 100644 --- a/packages/worker/src/api/controllers/admin/configs.js +++ b/packages/worker/src/api/controllers/admin/configs.js @@ -102,13 +102,23 @@ exports.publicSettings = async function (ctx) { const db = new CouchDB(GLOBAL_DB) try { // Find the config with the most granular scope based on context - const config = await getScopedFullConfig(db, { + const publicConfig = await getScopedFullConfig(db, { type: Configs.SETTINGS, }) - if (!config) { + + // Pull out the OIDC icon and name because the other properties shouldn't + // be made public + const oidcConfig = await getScopedFullConfig(db, { + type: Configs.OIDC, + }) + if (!publicConfig) { ctx.body = {} } else { - ctx.body = config + ctx.body = publicConfig + if (oidcConfig.config) { + publicConfig.config.oidcIcon = oidcConfig.config.iconName + publicConfig.config.oidcName = oidcConfig.config.name + } } } catch (err) { ctx.throw(err.status, err) @@ -122,12 +132,8 @@ exports.upload = async function (ctx) { const file = ctx.request.files.file const { type, name } = ctx.params - const fileExtension = [...file.name.split(".")].pop() - // filenames converted to UUIDs so they are unique - const processedFileName = `${name}.${fileExtension}` - const bucket = ObjectStoreBuckets.GLOBAL - const key = `${type}/${processedFileName}` + const key = `${type}/${name}` await upload({ bucket, filename: key,