don't show login component on logged in page, fix auth for app assets

This commit is contained in:
Martin McKeaveney 2020-10-14 16:47:53 +01:00
parent 802b05815d
commit 8132c77f8c
7 changed files with 51 additions and 71 deletions

View File

@ -1,21 +1,10 @@
<script>
import { setContext, onMount } from "svelte"
import { store } from "builderStore"
import {
LayoutIcon,
PaintIcon,
TerminalIcon,
CircleIndicator,
EventsIcon,
} from "components/common/Icons/"
import panelStructure from "./temporaryPanelStructure.js"
import CategoryTab from "./CategoryTab.svelte"
import DesignView from "./DesignView.svelte"
import SettingsView from "./SettingsView.svelte"
let current_view = "design"
let codeEditor
let flattenedPanel = flattenComponents(panelStructure.categories)
let categories = [
{ value: "settings", name: "Settings" },
@ -23,7 +12,6 @@
]
let selectedCategory = categories[0]
$: components = $store.components
$: componentInstance =
$store.currentView !== "component"
? { ...$store.currentPreviewItem, ...$store.currentComponentInfo }

View File

@ -1,33 +1,13 @@
<script>
import { goto } from "@sveltech/routify"
import { splitName } from "./pagesParsing/splitRootComponentName.js"
import { store } from "builderStore"
import components from "./temporaryPanelStructure.js"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import CategoryTab from "./CategoryTab.svelte"
import {
find,
sortBy,
groupBy,
values,
filter,
map,
uniqBy,
flatten,
} from "lodash/fp"
import { pipe } from "components/common/core"
import Tab from "./ItemTab/Tab.svelte"
import { store } from "builderStore"
export let toggleTab
let selectTemplateDialog
let selectedTemplateInstance
let templateInstances = []
let selectedComponent = null
const categories = components.categories
let selectedCategory = categories[0]

View File

@ -1,8 +1,10 @@
<script>
import { createEventDispatcher } from "svelte"
import { store } from "builderStore"
import Item from "./Item.svelte"
const dispatch = createEventDispatcher()
import Item from "./Item.svelte"
export let list
let category = list
@ -21,10 +23,12 @@
</script>
{#if !list.isCategory}
<button class="back-button" on:click={() => (list = category)}>Back</button>
<button class="back-button" on:click={goBack}>Back</button>
{/if}
{#each list.children as item}
<Item {item} on:click={() => handleClick(item)} />
{#if !item.showOnPages || item.showOnPages.includes($store.currentPageName)}
<Item {item} on:click={() => handleClick(item)} />
{/if}
{/each}
<style>

View File

@ -1198,39 +1198,40 @@ export default {
],
},
},
// {
// name: "Login",
// _component: "@budibase/standard-components/login",
// description:
// "A component that automatically generates a login screen for your app.",
// icon: "ri-login-box-line",
// children: [],
// properties: {
// design: { ...all },
// settings: [
// {
// label: "Name",
// key: "name",
// control: Input,
// },
// {
// label: "Logo",
// key: "logo",
// control: Input,
// },
// {
// label: "Title",
// key: "title",
// control: Input,
// },
// {
// label: "Button Text",
// key: "buttonText",
// control: Input,
// },
// ],
// },
// },
{
name: "Login",
_component: "@budibase/standard-components/login",
description:
"A component that automatically generates a login screen for your app.",
icon: "ri-login-box-line",
children: [],
showOnPages: ["unauthenticated"],
properties: {
design: { ...all },
settings: [
{
label: "Name",
key: "name",
control: Input,
},
{
label: "Logo",
key: "logo",
control: Input,
},
{
label: "Title",
key: "title",
control: Input,
},
{
label: "Button Text",
key: "buttonText",
control: Input,
},
],
},
},
],
},
],

View File

@ -31,8 +31,12 @@ module.exports = async (ctx, next) => {
if (!token) {
ctx.auth.authenticated = false
const appId = process.env.CLOUD ? ctx.subdomains[1] : ctx.params.appId
ctx.user = {
appId: process.env.CLOUD ? ctx.subdomains[1] : ctx.params.appId,
// if appId can't be determined from path param or subdomain
appId: appId || ctx.referer.split("/").pop(),
}
await next()
return

View File

@ -34,6 +34,9 @@ module.exports = (permName, getItemId) => async (ctx, next) => {
ctx.throw(403, "API key invalid")
}
// don't expose builder endpoints in the cloud
if (environment.CLOUD && permName === BUILDER) return
if (!ctx.auth.authenticated) {
ctx.throw(403, "Session not authenticated")
}

View File

@ -27,4 +27,4 @@
on:newRow={() => dispatch('newRow')} />
</DropdownMenu> -->
<!--<style ✂prettier:content✂="CiAgZGl2IHsKICAgIGRpc3BsYXk6IGdyaWQ7CiAgICBncmlkLXRlbXBsYXRlLWNvbHVtbnM6IGF1dG8gYXV0bzsKICAgIHBsYWNlLWl0ZW1zOiBzdGFydCBjZW50ZXI7CiAgfQogIGg1IHsKICAgIHBhZGRpbmc6IHZhcigtLXNwYWNpbmcteGwpIDAgMCB2YXIoLS1zcGFjaW5nLXhsKTsKICAgIG1hcmdpbjogMDsKICAgIGZvbnQtd2VpZ2h0OiA1MDA7CiAgfQo=" ✂prettier:content✂="" ✂prettier:content✂=""></style>-->
<!--<style ✂prettier:content✂="CiAgZGl2IHsKICAgIGRpc3BsYXk6IGdyaWQ7CiAgICBncmlkLXRlbXBsYXRlLWNvbHVtbnM6IGF1dG8gYXV0bzsKICAgIHBsYWNlLWl0ZW1zOiBzdGFydCBjZW50ZXI7CiAgfQogIGg1IHsKICAgIHBhZGRpbmc6IHZhcigtLXNwYWNpbmcteGwpIDAgMCB2YXIoLS1zcGFjaW5nLXhsKTsKICAgIG1hcmdpbjogMDsKICAgIGZvbnQtd2VpZ2h0OiA1MDA7CiAgfQo=" ✂prettier:content✂="" ✂prettier:content✂="" ✂prettier:content✂="" ✂prettier:content✂=""></style>-->