Adding mechanism to disable org functionality when multi-tenancy disabled.
This commit is contained in:
parent
a9752c0939
commit
be1558e1e7
|
@ -87,7 +87,8 @@ exports.getGlobalDB = tenantId => {
|
||||||
exports.getGlobalDBFromCtx = ctx => {
|
exports.getGlobalDBFromCtx = ctx => {
|
||||||
const user = ctx.user || {}
|
const user = ctx.user || {}
|
||||||
const params = ctx.request.params || {}
|
const params = ctx.request.params || {}
|
||||||
return exports.getGlobalDB(user.tenantId || params.tenantId)
|
const query = ctx.request.query || {}
|
||||||
|
return exports.getGlobalDB(user.tenantId || params.tenantId || query.tenantId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
Layout,
|
Layout,
|
||||||
Input,
|
Input,
|
||||||
Body,
|
Body,
|
||||||
|
ActionButton,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { goto } from "@roxi/routify"
|
import { goto } from "@roxi/routify"
|
||||||
import api from "builderStore/api"
|
import api from "builderStore/api"
|
||||||
|
@ -17,6 +18,7 @@
|
||||||
let error
|
let error
|
||||||
|
|
||||||
$: tenantId = $auth.tenantId
|
$: tenantId = $auth.tenantId
|
||||||
|
$: multiTenancyEnabled = $admin.multiTenancy
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
try {
|
try {
|
||||||
|
@ -34,6 +36,11 @@
|
||||||
notifications.error(`Failed to create admin user`)
|
notifications.error(`Failed to create admin user`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeOrg() {
|
||||||
|
auth.setOrg(null)
|
||||||
|
$goto("../auth")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
@ -50,9 +57,16 @@
|
||||||
<Input label="Email" bind:value={adminUser.email} />
|
<Input label="Email" bind:value={adminUser.email} />
|
||||||
<PasswordRepeatInput bind:password={adminUser.password} bind:error />
|
<PasswordRepeatInput bind:password={adminUser.password} bind:error />
|
||||||
</Layout>
|
</Layout>
|
||||||
<Button cta disabled={error} on:click={save}>
|
<Layout gap="XS" noPadding>
|
||||||
Create super admin user
|
<Button cta disabled={error} on:click={save}>
|
||||||
</Button>
|
Create super admin user
|
||||||
|
</Button>
|
||||||
|
{#if multiTenancyEnabled}
|
||||||
|
<ActionButton quiet on:click={changeOrg}>
|
||||||
|
Change organisation
|
||||||
|
</ActionButton>
|
||||||
|
{/if}
|
||||||
|
</Layout>
|
||||||
</Layout>
|
</Layout>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -6,10 +6,12 @@
|
||||||
Layout,
|
Layout,
|
||||||
Body,
|
Body,
|
||||||
Heading,
|
Heading,
|
||||||
|
ActionButton,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { organisation, auth } from "stores/portal"
|
import {organisation, auth} from "stores/portal"
|
||||||
import Logo from "assets/bb-emblem.svg"
|
import Logo from "assets/bb-emblem.svg"
|
||||||
import { onMount } from "svelte"
|
import {onMount} from "svelte"
|
||||||
|
import {goto} from "@roxi/routify"
|
||||||
|
|
||||||
let email = ""
|
let email = ""
|
||||||
|
|
||||||
|
@ -41,9 +43,14 @@
|
||||||
</Body>
|
</Body>
|
||||||
<Input label="Email" bind:value={email} />
|
<Input label="Email" bind:value={email} />
|
||||||
</Layout>
|
</Layout>
|
||||||
<Button cta on:click={forgot} disabled={!email}>
|
<Layout gap="XS" nopadding>
|
||||||
Reset your password
|
<Button cta on:click={forgot} disabled={!email}>
|
||||||
</Button>
|
Reset your password
|
||||||
|
</Button>
|
||||||
|
<ActionButton quiet on:click={() => $goto("../")}>
|
||||||
|
Back
|
||||||
|
</ActionButton>
|
||||||
|
</Layout>
|
||||||
</Layout>
|
</Layout>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
let loaded = false
|
let loaded = false
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
console.log(loaded)
|
|
||||||
if (loaded && multiTenancyEnabled && !tenantSet) {
|
if (loaded && multiTenancyEnabled && !tenantSet) {
|
||||||
$redirect("./org")
|
$redirect("./org")
|
||||||
} else if (loaded) {
|
} else if (loaded) {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
notifications,
|
notifications,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { goto, params } from "@roxi/routify"
|
import { goto, params } from "@roxi/routify"
|
||||||
import { auth, organisation, oidc } from "stores/portal"
|
import {auth, organisation, oidc, admin} from "stores/portal"
|
||||||
import GoogleButton from "./_components/GoogleButton.svelte"
|
import GoogleButton from "./_components/GoogleButton.svelte"
|
||||||
import OIDCButton from "./_components/OIDCButton.svelte"
|
import OIDCButton from "./_components/OIDCButton.svelte"
|
||||||
import Logo from "assets/bb-emblem.svg"
|
import Logo from "assets/bb-emblem.svg"
|
||||||
|
@ -18,8 +18,10 @@
|
||||||
|
|
||||||
let username = ""
|
let username = ""
|
||||||
let password = ""
|
let password = ""
|
||||||
|
let loaded = false
|
||||||
|
|
||||||
$: company = $organisation.company || "Budibase"
|
$: company = $organisation.company || "Budibase"
|
||||||
|
$: multiTenancyEnabled = $admin.multiTenancy
|
||||||
|
|
||||||
async function login() {
|
async function login() {
|
||||||
try {
|
try {
|
||||||
|
@ -49,6 +51,7 @@
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await organisation.init()
|
await organisation.init()
|
||||||
|
loaded = true
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -60,8 +63,10 @@
|
||||||
<img alt="logo" src={$organisation.logoUrl || Logo} />
|
<img alt="logo" src={$organisation.logoUrl || Logo} />
|
||||||
<Heading>Sign in to {company}</Heading>
|
<Heading>Sign in to {company}</Heading>
|
||||||
</Layout>
|
</Layout>
|
||||||
<GoogleButton />
|
{#if loaded}
|
||||||
<OIDCButton oidcIcon={$oidc.logo} oidcName={$oidc.name} />
|
<GoogleButton />
|
||||||
|
<OIDCButton oidcIcon={$oidc.logo} oidcName={$oidc.name} />
|
||||||
|
{/if}
|
||||||
<Divider noGrid />
|
<Divider noGrid />
|
||||||
<Layout gap="XS" noPadding>
|
<Layout gap="XS" noPadding>
|
||||||
<Body size="S" textAlign="center">Sign in with email</Body>
|
<Body size="S" textAlign="center">Sign in with email</Body>
|
||||||
|
@ -78,9 +83,11 @@
|
||||||
<ActionButton quiet on:click={() => $goto("./forgot")}>
|
<ActionButton quiet on:click={() => $goto("./forgot")}>
|
||||||
Forgot password?
|
Forgot password?
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
<ActionButton quiet on:click={() => $goto("./org")}>
|
{#if multiTenancyEnabled}
|
||||||
Change organisation
|
<ActionButton quiet on:click={() => $goto("./org")}>
|
||||||
</ActionButton>
|
Change organisation
|
||||||
|
</ActionButton>
|
||||||
|
{/if}
|
||||||
</Layout>
|
</Layout>
|
||||||
</Layout>
|
</Layout>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,10 +3,14 @@
|
||||||
import { goto } from "@roxi/routify"
|
import { goto } from "@roxi/routify"
|
||||||
import { auth, admin } from "stores/portal"
|
import { auth, admin } from "stores/portal"
|
||||||
import Logo from "assets/bb-emblem.svg"
|
import Logo from "assets/bb-emblem.svg"
|
||||||
|
import { get } from "svelte/store"
|
||||||
|
|
||||||
let tenantId = ""
|
let tenantId = get(auth).tenantSet ? get(auth).tenantId : ""
|
||||||
|
|
||||||
async function setOrg() {
|
async function setOrg() {
|
||||||
|
if (tenantId == null || tenantId === "") {
|
||||||
|
tenantId = "default"
|
||||||
|
}
|
||||||
auth.setOrg(tenantId)
|
auth.setOrg(tenantId)
|
||||||
// re-init now org selected
|
// re-init now org selected
|
||||||
await admin.init()
|
await admin.init()
|
||||||
|
|
|
@ -248,8 +248,6 @@
|
||||||
const oidcResponse = await api.get(`/api/admin/configs/${ConfigTypes.OIDC}`)
|
const oidcResponse = await api.get(`/api/admin/configs/${ConfigTypes.OIDC}`)
|
||||||
const oidcDoc = await oidcResponse.json()
|
const oidcDoc = await oidcResponse.json()
|
||||||
if (!oidcDoc._id) {
|
if (!oidcDoc._id) {
|
||||||
console.log("hi")
|
|
||||||
|
|
||||||
providers.oidc = {
|
providers.oidc = {
|
||||||
type: ConfigTypes.OIDC,
|
type: ConfigTypes.OIDC,
|
||||||
config: { configs: [{ activated: true }] },
|
config: { configs: [{ activated: true }] },
|
||||||
|
|
|
@ -52,7 +52,7 @@ export function createAuthStore() {
|
||||||
setOrg: tenantId => {
|
setOrg: tenantId => {
|
||||||
auth.update(store => {
|
auth.update(store => {
|
||||||
store.tenantId = tenantId
|
store.tenantId = tenantId
|
||||||
store.tenantSet = true
|
store.tenantSet = !!tenantId
|
||||||
return store
|
return store
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue