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 1601a9b2a2
commit a8dfb34112
7 changed files with 51 additions and 71 deletions

View File

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

View File

@ -1,33 +1,13 @@
<script> <script>
import { goto } from "@sveltech/routify" import { goto } from "@sveltech/routify"
import { splitName } from "./pagesParsing/splitRootComponentName.js" import { store } from "builderStore"
import components from "./temporaryPanelStructure.js" import components from "./temporaryPanelStructure.js"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import CategoryTab from "./CategoryTab.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 Tab from "./ItemTab/Tab.svelte"
import { store } from "builderStore"
export let toggleTab export let toggleTab
let selectTemplateDialog
let selectedTemplateInstance
let templateInstances = []
let selectedComponent = null
const categories = components.categories const categories = components.categories
let selectedCategory = categories[0] let selectedCategory = categories[0]

View File

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

View File

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

View File

@ -31,8 +31,12 @@ module.exports = async (ctx, next) => {
if (!token) { if (!token) {
ctx.auth.authenticated = false ctx.auth.authenticated = false
const appId = process.env.CLOUD ? ctx.subdomains[1] : ctx.params.appId
ctx.user = { 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() await next()
return return

View File

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

View File

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