diff --git a/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte b/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte index ffd870c213..d895ab8fbc 100644 --- a/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte +++ b/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte @@ -1,11 +1,10 @@ {#if show} diff --git a/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte b/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte index 2e11454081..e8a9ac86ce 100644 --- a/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte +++ b/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte @@ -4,10 +4,10 @@ import Auth0Logo from "assets/auth0-logo.png" import MicrosoftLogo from "assets/microsoft-logo.png" - import { oidc } from "stores/portal" + import { oidc, organisation } from "stores/portal" import { onMount } from "svelte" - let show = false + $: show = $organisation.oidc let preDefinedIcons = { Oidc: OidcLogo, @@ -19,7 +19,6 @@ await oidc.init() }) - $: show = $admin.checklist?.oidc $: src = !$oidc.logo ? OidcLogo : preDefinedIcons[$oidc.logo] || `/global/logos_oidc/${$oidc.logo}` diff --git a/packages/builder/src/stores/portal/organisation.js b/packages/builder/src/stores/portal/organisation.js index 7e6a777cd4..e7a9c3eea6 100644 --- a/packages/builder/src/stores/portal/organisation.js +++ b/packages/builder/src/stores/portal/organisation.js @@ -6,6 +6,8 @@ const DEFAULT_CONFIG = { logoUrl: undefined, docsUrl: undefined, company: "Budibase", + oidc: undefined, + google: undefined, } export function createOrganisationStore() { @@ -15,7 +17,7 @@ export function createOrganisationStore() { async function init() { const res = await api.get(`/api/admin/configs/public`) const json = await res.json() - + console.log(json) if (json.status === 400) { set(DEFAULT_CONFIG) } else { diff --git a/packages/worker/src/api/controllers/admin/configs.js b/packages/worker/src/api/controllers/admin/configs.js index 802141310b..5e7575498a 100644 --- a/packages/worker/src/api/controllers/admin/configs.js +++ b/packages/worker/src/api/controllers/admin/configs.js @@ -125,16 +125,34 @@ 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, { type: Configs.SETTINGS, }) - if (!publicConfig) { + const googleConfig = await getScopedFullConfig(db, { + type: Configs.GOOGLE, + }) + + const oidcConfig = await getScopedFullConfig(db, { + 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 { - ctx.body = publicConfig + if (publicConfig) { + config.config = publicConfig.config + } + config.config.oidc = !!oidcConfig + config.config.google = !!googleConfig + ctx.body = config } } catch (err) { ctx.throw(err.status, err)