Some updates, still WIP.
This commit is contained in:
parent
43f9deef4d
commit
98157f076f
|
@ -61,7 +61,7 @@ exports.fetchAppPackage = async function(ctx) {
|
||||||
const db = new CouchDB(ctx.params.appId)
|
const db = new CouchDB(ctx.params.appId)
|
||||||
const application = await db.get(ctx.params.appId)
|
const application = await db.get(ctx.params.appId)
|
||||||
ctx.body = await getPackageForBuilder(ctx.config, application)
|
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) {
|
exports.create = async function(ctx) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ exports.authenticate = async ctx => {
|
||||||
const expires = new Date()
|
const expires = new Date()
|
||||||
expires.setDate(expires.getDate() + 1)
|
expires.setDate(expires.getDate() + 1)
|
||||||
|
|
||||||
ctx.cookies.set("budibase:token", token, {
|
ctx.cookies.set(`budibase:token`, token, {
|
||||||
expires,
|
expires,
|
||||||
path: "/",
|
path: "/",
|
||||||
httpOnly: false,
|
httpOnly: false,
|
||||||
|
|
|
@ -21,7 +21,7 @@ const COMP_LIB_BASE_APP_VERSION = "0.2.5"
|
||||||
exports.serveBuilder = async function(ctx) {
|
exports.serveBuilder = async function(ctx) {
|
||||||
let builderPath = resolve(__dirname, "../../../builder")
|
let builderPath = resolve(__dirname, "../../../builder")
|
||||||
if (ctx.file === "index.html") {
|
if (ctx.file === "index.html") {
|
||||||
setBuilderToken(ctx)
|
await setBuilderToken(ctx)
|
||||||
}
|
}
|
||||||
await send(ctx, ctx.file, { root: ctx.devPath || builderPath })
|
await send(ctx, ctx.file, { root: ctx.devPath || builderPath })
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ const createUserWithPermissions = async (
|
||||||
|
|
||||||
const loginResult = await request
|
const loginResult = await request
|
||||||
.post(`/api/authenticate`)
|
.post(`/api/authenticate`)
|
||||||
.set({ Cookie: `budibase:token=${anonToken}` })
|
.set({ Cookie: `budibase:${appId}=${anonToken}` })
|
||||||
.send({ username, password })
|
.send({ username, password })
|
||||||
|
|
||||||
// returning necessary request headers
|
// returning necessary request headers
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
const { BUILDER_LEVEL_ID } = require("../accessLevels")
|
const { BUILDER_LEVEL_ID } = require("../accessLevels")
|
||||||
const env = require("../../environment")
|
const env = require("../../environment")
|
||||||
|
const CouchDB = require("../../db")
|
||||||
const jwt = require("jsonwebtoken")
|
const jwt = require("jsonwebtoken")
|
||||||
|
|
||||||
module.exports = (ctx, appId, version) => {
|
module.exports = async (ctx, appId, version) => {
|
||||||
const builderUser = {
|
const builderUser = {
|
||||||
userId: "BUILDER",
|
userId: "BUILDER",
|
||||||
accessLevelId: BUILDER_LEVEL_ID,
|
accessLevelId: BUILDER_LEVEL_ID,
|
||||||
|
@ -18,14 +19,16 @@ module.exports = (ctx, appId, version) => {
|
||||||
|
|
||||||
const expiry = new Date()
|
const expiry = new Date()
|
||||||
expiry.setDate(expiry.getDate() + 30)
|
expiry.setDate(expiry.getDate() + 30)
|
||||||
// remove the app token
|
|
||||||
ctx.cookies.set("budibase:token", "", {
|
|
||||||
overwrite: true,
|
|
||||||
})
|
|
||||||
// set the builder token
|
// set the builder token
|
||||||
ctx.cookies.set("builder:token", token, {
|
ctx.cookies.set("builder:token", token, {
|
||||||
expires: expiry,
|
expires: expiry,
|
||||||
httpOnly: false,
|
httpOnly: false,
|
||||||
overwrite: true,
|
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,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,3 +10,7 @@ exports.isDev = () => {
|
||||||
env.NODE_ENV !== "cypress"
|
env.NODE_ENV !== "cypress"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.getAppId = ctx => {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue