1
0
Fork 0
mirror of synced 2024-06-02 18:44:54 +12:00

Linting and Optimisation

This commit is contained in:
Peter Clement 2021-07-09 15:05:39 +01:00
parent 4ae29f6b54
commit 90e6db2be1
6 changed files with 34 additions and 35 deletions

View file

@ -15,18 +15,21 @@
Oidc: OidcLogo,
Oracle: OracleLogo,
Auth0: Auth0Logo,
AD: MicrosoftLogo
AD: MicrosoftLogo,
}
$: show = $admin.checklist?.oidc
</script>
{#if show}
<ActionButton
on:click={() => window.open("/api/admin/auth/oidc", "_blank")}
>
<ActionButton on:click={() => window.open("/api/admin/auth/oidc", "_blank")}>
<div class="inner">
<img src={preDefinedIcons[oidcIcon] ? preDefinedIcons[oidcIcon] : `/global/oidc_logos/${oidcIcon}` || OidcLogo} alt="oidc icon" />
<p>{`Sign in with ${oidcName || 'OIDC'}`}</p>
<img
src={preDefinedIcons[oidcIcon]
? preDefinedIcons[oidcIcon]
: `/global/oidc_logos/${oidcIcon}` || OidcLogo}
alt="oidc icon"
/>
<p>{`Sign in with ${oidcName || "OIDC"}`}</p>
</div>
</ActionButton>
{/if}
@ -48,4 +51,3 @@
margin: 0;
}
</style>

View file

@ -62,7 +62,10 @@
<Heading>Sign in to {company}</Heading>
</Layout>
<GoogleButton />
<OIDCButton oidcIcon={$organisation.oidcIcon} oidcName={$organisation.oidcName}/>
<OIDCButton
oidcIcon={$organisation.oidcIcon}
oidcName={$organisation.oidcName}
/>
<Divider noGrid />
<Layout gap="XS" noPadding>
<Body size="S" textAlign="center">Sign in with email</Body>

View file

@ -19,6 +19,13 @@
} from "@budibase/bbui"
import { onMount } from "svelte"
import api from "builderStore/api"
import { writable } from "svelte/store"
import { organisation } from "stores/portal"
const values = writable({
oidcIcon: $organisation.oidcIcon,
oidcName: $organisation.oidcName,
})
const ConfigTypes = {
Google: "google",
@ -39,12 +46,12 @@
}
const OIDCConfigFields = {
Oidc: ["configUrl", "clientID", "clientSecret"],
Oidc: ["configUrl", "clientId", "clientSecret"],
}
const OIDCConfigLabels = {
Oidc: {
configUrl: "Config URL",
clientID: "Client ID",
clientId: "Client ID",
clientSecret: "Client Secret",
},
}
@ -81,8 +88,9 @@
const onFileSelected = e => {
let fileName = e.target.files[0].name
image = e.target.files[0]
providers.oidc.config["iconName"] = fileName
$values.oidcIcon = fileName
iconDropdownOptions.unshift({ label: fileName, value: fileName })
image && uploadLogo(image)
}
const providers = { google, oidc }
@ -90,6 +98,7 @@
async function save(docs) {
// only if the user has provided an image, upload it.
image && uploadLogo(image)
await organisation.save($values)
let calls = []
docs.forEach(element => {
calls.push(api.post(`/api/admin/configs`, element))
@ -116,6 +125,7 @@
}
onMount(async () => {
await organisation.init()
// fetch the configs for oauth
const googleResponse = await api.get(
`/api/admin/configs/${ConfigTypes.Google}`
@ -220,13 +230,13 @@
</Body>
<div class="form-row">
<Label size="L">Name</Label>
<Input bind:value={providers.oidc.config["name"]} />
<Input bind:value={$values.oidcName} />
</div>
<div class="form-row">
<Label size="L">Icon</Label>
<Select
label=""
bind:value={providers.oidc.config["iconName"]}
bind:value={$values.oidcIcon}
options={iconDropdownOptions}
on:change={e => e.detail === "Upload" && fileinput.click()}
/>

View file

@ -6,6 +6,8 @@ const DEFAULT_CONFIG = {
logoUrl: undefined,
docsUrl: undefined,
company: "Budibase",
oidcIcon: undefined,
oidcName: undefined,
}
export function createOrganisationStore() {

View file

@ -106,29 +106,11 @@ exports.publicSettings = async function (ctx) {
type: Configs.SETTINGS,
})
// Pull out the OIDC icon and name because the other properties shouldn't
// be made public
const oidcConfig = await getScopedFullConfig(db, {
type: Configs.OIDC,
})
if (publicConfig && !oidcConfig) {
if (!publicConfig) {
ctx.body = {}
} else {
ctx.body = publicConfig
}
else if(!publicConfig && oidcConfig) {
// Pull out the OIDC icon and name because the other properties shouldn't
// be made public
let config = {}
config.oidcIcon = oidcConfig.config.iconName
config.oidcName = oidcConfig.config.name
oidcConfig.config = config
ctx.body = oidcConfig
}
else if (publicConfig && oidcConfig) {
ctx.body = publicConfig
publicConfig.config.oidcIcon = oidcConfig.config.iconName
publicConfig.config.oidcName = oidcConfig.config.name
}
} catch (err) {
ctx.throw(err.status, err)
}

View file

@ -66,7 +66,7 @@ function buildConfigSaveValidation() {
{ is: Configs.SETTINGS, then: settingValidation() },
{ is: Configs.ACCOUNT, then: Joi.object().unknown(true) },
{ is: Configs.GOOGLE, then: googleValidation() },
{ is: Configs.OIDC, then: Joi.object().unknown(true) }
{ is: Configs.OIDC, then: oidcValidation() }
],
}),
}).required(),