Browse Source

Default public config.config when missing

gh-pages
Rory Powell 5 years ago
parent
commit
25fdde6d21
  1. 25
      packages/worker/src/api/controllers/admin/configs.js

25
packages/worker/src/api/controllers/admin/configs.js

@ -125,7 +125,7 @@ exports.publicOidc = async function (ctx) {
exports.publicSettings = async function (ctx) {
const db = new CouchDB(GLOBAL_DB)
let config = {}
try {
// Find the config with the most granular scope based on context
const publicConfig = await getScopedFullConfig(db, {
@ -140,20 +140,19 @@ exports.publicSettings = async function (ctx) {
type: Configs.OIDC,
})
// Slightly complex logic here to deal with the fact that
// oidc / google might be enabled but org name etc (publicConfig) might not
if (publicConfig && !!googleConfig && !!oidcConfig) {
ctx.body = publicConfig
} else if (!publicConfig && !!googleConfig && !!oidcConfig) {
ctx.body = {}
} else {
if (publicConfig) {
config.config = publicConfig.config
let config = {}
if (!publicConfig) {
config = {
config: {},
}
config.config.oidc = !!oidcConfig
config.config.google = !!googleConfig
ctx.body = config
} else {
config = publicConfig
}
config.config.oidc = !!oidcConfig
config.config.google = !!googleConfig
ctx.body = config
} catch (err) {
ctx.throw(err.status, err)
}

Loading…
Cancel
Save