From 41e3e2d77415d153c50679eb38e597fc09429ac5 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 8 Jan 2025 16:52:33 +0000 Subject: [PATCH] Improve handling of configs --- packages/builder/src/stores/portal/oidc.ts | 12 ++++-------- packages/frontend-core/src/api/configs.ts | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/builder/src/stores/portal/oidc.ts b/packages/builder/src/stores/portal/oidc.ts index a914645135..6c3609f9d5 100644 --- a/packages/builder/src/stores/portal/oidc.ts +++ b/packages/builder/src/stores/portal/oidc.ts @@ -11,14 +11,10 @@ class OIDCStore extends BudiStore { async init() { const tenantId = get(auth).tenantId - const config = await API.getOIDCConfig(tenantId) - if (Object.keys(config || {}).length) { - // Just use the first config for now. - // We will be support multiple logins buttons later on. - this.set(config[0]) - } else { - this.set({}) - } + const configs = await API.getOIDCConfigs(tenantId) + // Just use the first config for now. + // We will be support multiple logins buttons later on. + this.set(configs[0] || {}) } } diff --git a/packages/frontend-core/src/api/configs.ts b/packages/frontend-core/src/api/configs.ts index 82f08e58a7..408180a859 100644 --- a/packages/frontend-core/src/api/configs.ts +++ b/packages/frontend-core/src/api/configs.ts @@ -16,7 +16,7 @@ import { BaseAPIClient } from "./types" export interface ConfigEndpoints { getConfig: (type: ConfigType) => Promise getTenantConfig: (tentantId: string) => Promise - getOIDCConfig: (tenantId: string) => Promise + getOIDCConfigs: (tenantId: string) => Promise getOIDCLogos: () => Promise> saveConfig: (config: SaveConfigRequest) => Promise deleteConfig: (id: string, rev: string) => Promise @@ -73,7 +73,7 @@ export const buildConfigEndpoints = (API: BaseAPIClient): ConfigEndpoints => ({ * Gets the OIDC config for a certain tenant. * @param tenantId the tenant ID to get the config for */ - getOIDCConfig: async tenantId => { + getOIDCConfigs: async tenantId => { return await API.get({ url: `/api/global/configs/public/oidc?tenantId=${tenantId}`, })