Some changes for authentication and getting rid of allScreens component of store as it was causing confusion and breakages.

This commit is contained in:
mike12345567 2020-10-15 13:52:56 +01:00
parent 0fe97feb25
commit bbe085f734
8 changed files with 18 additions and 11 deletions

View File

@ -106,10 +106,6 @@ const setPackage = (store, initial) => async pkg => {
initial.pages = pkg.pages initial.pages = pkg.pages
initial.hasAppPackage = true initial.hasAppPackage = true
initial.screens = values(pkg.screens) initial.screens = values(pkg.screens)
initial.allScreens = [
...Object.values(main_screens),
...Object.values(unauth_screens),
]
initial.builtins = [getBuiltin("##builtin/screenslot")] initial.builtins = [getBuiltin("##builtin/screenslot")]
initial.appInstances = pkg.application.instances initial.appInstances = pkg.application.instances
initial.appId = pkg.application._id initial.appId = pkg.application._id
@ -139,7 +135,6 @@ const _saveScreen = async (store, s, screen) => {
innerState.pages[pageName]._screens = screens innerState.pages[pageName]._screens = screens
innerState.screens = screens innerState.screens = screens
innerState.currentPreviewItem = screen innerState.currentPreviewItem = screen
innerState.allScreens = [...innerState.allScreens, screen]
const safeProps = makePropsSafe( const safeProps = makePropsSafe(
innerState.components[screen.props._component], innerState.components[screen.props._component],
screen.props screen.props

View File

@ -52,6 +52,8 @@
.map(template => template.create()) .map(template => template.create())
for (let screen of screens) { for (let screen of screens) {
// record the table that created this screen so we can link it later
screen.autoTableId = table._id
try { try {
await store.createScreen(screen) await store.createScreen(screen)
} catch (_) { } catch (_) {

View File

@ -30,8 +30,8 @@
} }
function showModal() { function showModal() {
const screens = $store.allScreens const screens = $store.screens
templateScreens = screens.filter(screen => screen.props.table === table._id) templateScreens = screens.filter(screen => screen.autoTableId === table._id)
willBeDeleted = ["All table data"].concat( willBeDeleted = ["All table data"].concat(
templateScreens.map(screen => `Screen ${screen.props._instanceName}`) templateScreens.map(screen => `Screen ${screen.props._instanceName}`)
) )

View File

@ -29,7 +29,7 @@
{:else if parameter.name === 'url'} {:else if parameter.name === 'url'}
<DataList on:change bind:value={parameter.value}> <DataList on:change bind:value={parameter.value}>
<option value="" /> <option value="" />
{#each $store.allScreens as screen} {#each $store.screens as screen}
<option value={screen.route}>{screen.props._instanceName}</option> <option value={screen.route}>{screen.props._instanceName}</option>
{/each} {/each}
</DataList> </DataList>

View File

@ -70,6 +70,7 @@ exports.authenticate = async ctx => {
expires, expires,
path: "/", path: "/",
httpOnly: false, httpOnly: false,
overwrite: true,
}) })
ctx.body = { ctx.body = {

View File

@ -51,6 +51,7 @@ module.exports = async (ctx, next) => {
ctx.auth.apiKey = jwtPayload.apiKey ctx.auth.apiKey = jwtPayload.apiKey
ctx.user = { ctx.user = {
...jwtPayload, ...jwtPayload,
instanceId: jwtPayload.instanceId,
accessLevel: await getAccessLevel( accessLevel: await getAccessLevel(
jwtPayload.instanceId, jwtPayload.instanceId,
jwtPayload.accessLevelId jwtPayload.accessLevelId

View File

@ -15,7 +15,16 @@ module.exports = (ctx, appId, instanceId) => {
expiresIn: "30 days", expiresIn: "30 days",
}) })
var expiry = new Date() const expiry = new Date()
expiry.setDate(expiry.getDate() + 30) expiry.setDate(expiry.getDate() + 30)
ctx.cookies.set("builder:token", token, { expires: expiry, httpOnly: false }) // remove the app token
ctx.cookies.set("budibase:token", "", {
overwrite: true,
})
// set the builder token
ctx.cookies.set("builder:token", token, {
expires: expiry,
httpOnly: false,
overwrite: true,
})
} }

View File

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