|
|
|
@ -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, |
|
|
|
}) |
|
|
|
} |
|
|
|
|