From 8673ed1dae81f96372ca2b45d28f0a3483624ddd Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 31 Mar 2023 14:03:34 +0100 Subject: [PATCH 1/2] Minor improvement - opening the google authorization in the same tab as onboarding rather than creating a dead tab. --- .../_components/GoogleButton.svelte | 11 +++++++---- .../_components/DatasourceConfigPanel.svelte | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/_components/GoogleButton.svelte b/packages/builder/src/components/backend/DatasourceNavigator/_components/GoogleButton.svelte index 0cf92dde2b..b7d70d88b7 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/_components/GoogleButton.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/_components/GoogleButton.svelte @@ -6,6 +6,7 @@ export let preAuthStep export let datasource export let disabled + export let samePage $: tenantId = $auth.tenantId @@ -25,10 +26,12 @@ ds = resp } } - window.open( - `/api/global/auth/${tenantId}/datasource/google?datasourceId=${ds._id}&appId=${appId}`, - "_blank" - ) + const url = `/api/global/auth/${tenantId}/datasource/google?datasourceId=${ds._id}&appId=${appId}` + if (samePage) { + window.location = url + } else { + window.open(url, "_blank") + } }} > google icon diff --git a/packages/builder/src/pages/builder/portal/apps/onboarding/_components/DatasourceConfigPanel.svelte b/packages/builder/src/pages/builder/portal/apps/onboarding/_components/DatasourceConfigPanel.svelte index 333cfdb0c6..2b44648279 100644 --- a/packages/builder/src/pages/builder/portal/apps/onboarding/_components/DatasourceConfigPanel.svelte +++ b/packages/builder/src/pages/builder/portal/apps/onboarding/_components/DatasourceConfigPanel.svelte @@ -107,7 +107,7 @@ {#if isGoogle} - + {:else} {/if} From ea70b6232fa14f8432e6be6a92380277e478d0f3 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 31 Mar 2023 14:52:18 +0100 Subject: [PATCH 2/2] Making login page open SSO authorization on same page, rather than leaving a dead tab. --- .../builder/auth/_components/GoogleButton.svelte | 11 +++++++++-- .../builder/auth/_components/OIDCButton.svelte | 15 ++++++++++----- .../builder/src/pages/builder/auth/login.svelte | 4 ++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte b/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte index d8e1da7072..812f744087 100644 --- a/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte +++ b/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte @@ -3,6 +3,7 @@ import GoogleLogo from "assets/google-logo.png" import { auth, organisation } from "stores/portal" + export let samePage let show $: tenantId = $auth.tenantId @@ -12,8 +13,14 @@ {#if show} - window.open(`/api/global/auth/${tenantId}/google`, "_blank")} + on:click={() => { + const url = `/api/global/auth/${tenantId}/google` + if (samePage) { + window.location = url + } else { + window.open(url, "_blank") + } + }} > Log in with Google diff --git a/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte b/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte index 396bde3cb0..1fa392610b 100644 --- a/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte +++ b/packages/builder/src/pages/builder/auth/_components/OIDCButton.svelte @@ -9,6 +9,8 @@ import { oidc, organisation, auth } from "stores/portal" import { onMount } from "svelte" + export let samePage + $: show = $organisation.oidc let preDefinedIcons = { @@ -35,11 +37,14 @@ {#if show} - window.open( - `/api/global/auth/${$auth.tenantId}/oidc/configs/${$oidc.uuid}`, - "_blank" - )} + on:click={() => { + const url = `/api/global/auth/${$auth.tenantId}/oidc/configs/${$oidc.uuid}` + if (samePage) { + window.location = url + } else { + window.open(url, "_blank") + } + }} > {`Log in with ${$oidc.name || "OIDC"}`} diff --git a/packages/builder/src/pages/builder/auth/login.svelte b/packages/builder/src/pages/builder/auth/login.svelte index 547c914621..9dae365add 100644 --- a/packages/builder/src/pages/builder/auth/login.svelte +++ b/packages/builder/src/pages/builder/auth/login.svelte @@ -78,8 +78,8 @@ {#if loaded && ($organisation.google || $organisation.oidc)} - - + + {/if} {#if !$organisation.isSSOEnforced}