diff --git a/packages/builder/src/pages/builder/_layout.svelte b/packages/builder/src/pages/builder/_layout.svelte index cde1d332b2..ce883ee541 100644 --- a/packages/builder/src/pages/builder/_layout.svelte +++ b/packages/builder/src/pages/builder/_layout.svelte @@ -4,7 +4,9 @@ import { onMount } from "svelte" let loaded = false + $: multiTenancyEnabled = $admin.multiTenancy $: hasAdminUser = !!$admin?.checklist?.adminUser + $: tenantSet = $auth.tenantSet onMount(async () => { await admin.init() @@ -14,7 +16,9 @@ // Force creation of an admin user if one doesn't exist $: { - if (loaded && !hasAdminUser) { + if (loaded && multiTenancyEnabled && !tenantSet) { + $redirect("./auth/org") + } else if (loaded && !hasAdminUser) { $redirect("./admin") } } diff --git a/packages/builder/src/pages/builder/admin/index.svelte b/packages/builder/src/pages/builder/admin/index.svelte index 4a6ded819a..cf882132ad 100644 --- a/packages/builder/src/pages/builder/admin/index.svelte +++ b/packages/builder/src/pages/builder/admin/index.svelte @@ -9,15 +9,18 @@ } from "@budibase/bbui" import { goto } from "@roxi/routify" import api from "builderStore/api" - import { admin } from "stores/portal" + import { admin, auth } from "stores/portal" import PasswordRepeatInput from "components/common/users/PasswordRepeatInput.svelte" import Logo from "assets/bb-emblem.svg" let adminUser = {} let error + $: tenantId = $auth.tenantId + async function save() { try { + adminUser.tenantId = tenantId // Save the admin user const response = await api.post(`/api/admin/users/init`, adminUser) const json = await response.json() @@ -44,7 +47,6 @@ - diff --git a/packages/builder/src/pages/builder/auth/index.svelte b/packages/builder/src/pages/builder/auth/index.svelte index d335c3dfba..bbdd9949ba 100644 --- a/packages/builder/src/pages/builder/auth/index.svelte +++ b/packages/builder/src/pages/builder/auth/index.svelte @@ -1,5 +1,24 @@ diff --git a/packages/builder/src/pages/builder/auth/org.svelte b/packages/builder/src/pages/builder/auth/org.svelte index 33692030b9..ee3f2b9d4a 100644 --- a/packages/builder/src/pages/builder/auth/org.svelte +++ b/packages/builder/src/pages/builder/auth/org.svelte @@ -1,14 +1,16 @@