Some updates, still WIP.

This commit is contained in:
Michael Drury 2020-11-02 15:46:08 +00:00
parent d9025d1aa1
commit c89f73efc0
6 changed files with 16 additions and 9 deletions

View File

@ -61,7 +61,7 @@ exports.fetchAppPackage = async function(ctx) {
const db = new CouchDB(ctx.params.appId)
const application = await db.get(ctx.params.appId)
ctx.body = await getPackageForBuilder(ctx.config, application)
setBuilderToken(ctx, ctx.params.appId, application.version)
await setBuilderToken(ctx, ctx.params.appId, application.version)
}
exports.create = async function(ctx) {

View File

@ -48,7 +48,7 @@ exports.authenticate = async ctx => {
const expires = new Date()
expires.setDate(expires.getDate() + 1)
ctx.cookies.set("budibase:token", token, {
ctx.cookies.set(`budibase:token`, token, {
expires,
path: "/",
httpOnly: false,

View File

@ -21,7 +21,7 @@ const COMP_LIB_BASE_APP_VERSION = "0.2.5"
exports.serveBuilder = async function(ctx) {
let builderPath = resolve(__dirname, "../../../builder")
if (ctx.file === "index.html") {
setBuilderToken(ctx)
await setBuilderToken(ctx)
}
await send(ctx, ctx.file, { root: ctx.devPath || builderPath })
}

View File

@ -209,7 +209,7 @@ const createUserWithPermissions = async (
const loginResult = await request
.post(`/api/authenticate`)
.set({ Cookie: `budibase:token=${anonToken}` })
.set({ Cookie: `budibase:${appId}=${anonToken}` })
.send({ username, password })
// returning necessary request headers

View File

@ -1,8 +1,9 @@
const { BUILDER_LEVEL_ID } = require("../accessLevels")
const env = require("../../environment")
const CouchDB = require("../../db")
const jwt = require("jsonwebtoken")
module.exports = (ctx, appId, version) => {
module.exports = async (ctx, appId, version) => {
const builderUser = {
userId: "BUILDER",
accessLevelId: BUILDER_LEVEL_ID,
@ -18,14 +19,16 @@ module.exports = (ctx, appId, version) => {
const expiry = new Date()
expiry.setDate(expiry.getDate() + 30)
// 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,
})
// need to clear all app tokens or else unable to use the app in the builder
let allDbNames = await CouchDB.allDbs()
allDbNames.map(dbName => {})
ctx.cookies.set(`budibase:${appId}`, "", {
overwrite: true,
})
}

View File

@ -10,3 +10,7 @@ exports.isDev = () => {
env.NODE_ENV !== "cypress"
)
}
exports.getAppId = ctx => {
}