add new logic to support oauth and oidc buttons
This commit is contained in:
parent
90c0e7b2c1
commit
4e75b7f4c9
|
@ -1,11 +1,10 @@
|
||||||
<script>
|
<script>
|
||||||
import { ActionButton } from "@budibase/bbui"
|
import { ActionButton } from "@budibase/bbui"
|
||||||
import GoogleLogo from "assets/google-logo.png"
|
import GoogleLogo from "assets/google-logo.png"
|
||||||
import { admin } from "stores/portal"
|
import { organisation } from "stores/portal"
|
||||||
|
|
||||||
let show = false
|
$: show = $organisation.google
|
||||||
|
console.log(show)
|
||||||
$: show = $admin.checklist?.oauth
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if show}
|
{#if show}
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
import Auth0Logo from "assets/auth0-logo.png"
|
import Auth0Logo from "assets/auth0-logo.png"
|
||||||
import MicrosoftLogo from "assets/microsoft-logo.png"
|
import MicrosoftLogo from "assets/microsoft-logo.png"
|
||||||
|
|
||||||
import { admin, oidc } from "stores/portal"
|
import { oidc, organisation } from "stores/portal"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
|
|
||||||
let show = false
|
$: show = $organisation.oidc
|
||||||
|
|
||||||
let preDefinedIcons = {
|
let preDefinedIcons = {
|
||||||
Oidc: OidcLogo,
|
Oidc: OidcLogo,
|
||||||
|
@ -19,7 +19,6 @@
|
||||||
await oidc.init()
|
await oidc.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
$: show = $admin.checklist?.oidc
|
|
||||||
$: src = !$oidc.logo
|
$: src = !$oidc.logo
|
||||||
? OidcLogo
|
? OidcLogo
|
||||||
: preDefinedIcons[$oidc.logo] || `/global/logos_oidc/${$oidc.logo}`
|
: preDefinedIcons[$oidc.logo] || `/global/logos_oidc/${$oidc.logo}`
|
||||||
|
|
|
@ -6,6 +6,8 @@ const DEFAULT_CONFIG = {
|
||||||
logoUrl: undefined,
|
logoUrl: undefined,
|
||||||
docsUrl: undefined,
|
docsUrl: undefined,
|
||||||
company: "Budibase",
|
company: "Budibase",
|
||||||
|
oidc: undefined,
|
||||||
|
google: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createOrganisationStore() {
|
export function createOrganisationStore() {
|
||||||
|
@ -15,7 +17,7 @@ export function createOrganisationStore() {
|
||||||
async function init() {
|
async function init() {
|
||||||
const res = await api.get(`/api/admin/configs/public`)
|
const res = await api.get(`/api/admin/configs/public`)
|
||||||
const json = await res.json()
|
const json = await res.json()
|
||||||
|
console.log(json)
|
||||||
if (json.status === 400) {
|
if (json.status === 400) {
|
||||||
set(DEFAULT_CONFIG)
|
set(DEFAULT_CONFIG)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -125,16 +125,34 @@ exports.publicOidc = async function (ctx) {
|
||||||
|
|
||||||
exports.publicSettings = async function (ctx) {
|
exports.publicSettings = async function (ctx) {
|
||||||
const db = new CouchDB(GLOBAL_DB)
|
const db = new CouchDB(GLOBAL_DB)
|
||||||
|
let config = {}
|
||||||
try {
|
try {
|
||||||
// Find the config with the most granular scope based on context
|
// Find the config with the most granular scope based on context
|
||||||
const publicConfig = await getScopedFullConfig(db, {
|
const publicConfig = await getScopedFullConfig(db, {
|
||||||
type: Configs.SETTINGS,
|
type: Configs.SETTINGS,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!publicConfig) {
|
const googleConfig = await getScopedFullConfig(db, {
|
||||||
|
type: Configs.GOOGLE,
|
||||||
|
})
|
||||||
|
|
||||||
|
const oidcConfig = await getScopedFullConfig(db, {
|
||||||
|
type: Configs.OIDC,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Slightly complex logic here to deal with the fact that
|
||||||
|
// oidc / google might be enabled but org name etc (publicConfig) might not
|
||||||
|
if (publicConfig && !!googleConfig && !!oidcConfig) {
|
||||||
|
ctx.body = publicConfig
|
||||||
|
} else if (!publicConfig && !!googleConfig && !!oidcConfig) {
|
||||||
ctx.body = {}
|
ctx.body = {}
|
||||||
} else {
|
} else {
|
||||||
ctx.body = publicConfig
|
if (publicConfig) {
|
||||||
|
config.config = publicConfig.config
|
||||||
|
}
|
||||||
|
config.config.oidc = !!oidcConfig
|
||||||
|
config.config.google = !!googleConfig
|
||||||
|
ctx.body = config
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
ctx.throw(err.status, err)
|
ctx.throw(err.status, err)
|
||||||
|
|
Loading…
Reference in New Issue