diff --git a/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte b/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte
index d895ab8fbc..c9a6aba218 100644
--- a/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte
+++ b/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte
@@ -4,7 +4,6 @@
import { organisation } from "stores/portal"
$: show = $organisation.google
- console.log(show)
{#if show}
diff --git a/packages/builder/src/pages/builder/portal/manage/auth/index.svelte b/packages/builder/src/pages/builder/portal/manage/auth/index.svelte
index f2c7981a27..7f132b5638 100644
--- a/packages/builder/src/pages/builder/portal/manage/auth/index.svelte
+++ b/packages/builder/src/pages/builder/portal/manage/auth/index.svelte
@@ -17,6 +17,7 @@
Input,
Body,
Select,
+ Toggle,
} from "@budibase/bbui"
import { onMount } from "svelte"
import api from "builderStore/api"
@@ -90,21 +91,30 @@
let google
let oidc
const providers = { google, oidc }
+ let googleSaveButtonDisabled
+ let oidcSaveButtonDisabled
+
+ $: googleSaveButtonDisabled =
+ providers.google?.config && !providers.google?.config.activated && true
+ $: oidcSaveButtonDisabled =
+ providers.oidc?.config.configs[0] &&
+ !providers.oidc?.config.configs[0].activated &&
+ true
// Create a flag so that it will only try to save completed forms
- $: trySaveGoogle =
- providers.google?.config.clientID ||
- providers.google?.config.clientSecret ||
- providers.google?.config.callbackURL
- $: trySaveOidc =
+ $: partialGoogle =
+ providers.google?.config?.clientID ||
+ providers.google?.config?.clientSecret ||
+ providers.google?.config?.callbackURL
+ $: partialOidc =
providers.oidc?.config?.configs[0].configUrl ||
providers.oidc?.config?.configs[0].clientID ||
providers.oidc?.config?.configs[0].clientSecret
$: googleComplete =
- providers.google?.config.clientID &&
- providers.google?.config.clientSecret &&
- providers.google?.config.callbackURL
+ providers.google?.config?.clientID &&
+ providers.google?.config?.clientSecret &&
+ providers.google?.config?.callbackURL
$: oidcComplete =
providers.oidc?.config?.configs[0].configUrl &&
providers.oidc?.config?.configs[0].clientID &&
@@ -128,6 +138,22 @@
iconDropdownOptions.unshift({ label: fileName, value: fileName })
}
+ const toggleGoogle = ({ detail }) => {
+ // Only save on de-activation, as the user can save themselves when toggle is active
+ if (!detail) {
+ providers.google.config.activated = detail
+ save([providers.google])
+ }
+ }
+
+ const toggleOidc = ({ detail }) => {
+ // Only save on de-activation, as the user can save themselves when toggle is active
+ if (!detail) {
+ providers.oidc.config.configs[0].activated = detail
+ save([providers.oidc])
+ }
+ }
+
async function save(docs) {
// only if the user has provided an image, upload it.
image && uploadLogo(image)
@@ -139,7 +165,7 @@
element.config.configs.forEach(config => {
!config.uuid && (config.uuid = uuid())
})
- if (trySaveOidc) {
+ if (partialOidc) {
if (!oidcComplete) {
notifications.error(
`Please fill in all required ${ConfigTypes.OIDC} fields`
@@ -151,7 +177,7 @@
}
}
if (element.type === ConfigTypes.Google) {
- if (trySaveGoogle) {
+ if (partialGoogle) {
if (!googleComplete) {
notifications.error(
`Please fill in all required ${ConfigTypes.Google} fields`
@@ -196,7 +222,7 @@
if (!googleDoc._id) {
providers.google = {
type: ConfigTypes.Google,
- config: {},
+ config: { activated: true },
}
} else {
providers.google = googleDoc
@@ -225,7 +251,7 @@
if (!oidcDoc._id) {
providers.oidc = {
type: ConfigTypes.OIDC,
- config: { configs: [{}] },
+ config: { configs: [{ activated: true }] },
}
} else {
providers.oidc = oidcDoc
@@ -246,10 +272,20 @@