|
|
@ -2,6 +2,9 @@ const { BUILDER_LEVEL_ID } = require("../accessLevels") |
|
|
const env = require("../../environment") |
|
|
const env = require("../../environment") |
|
|
const CouchDB = require("../../db") |
|
|
const CouchDB = require("../../db") |
|
|
const jwt = require("jsonwebtoken") |
|
|
const jwt = require("jsonwebtoken") |
|
|
|
|
|
const { DocumentTypes, SEPARATOR } = require("../../db/utils") |
|
|
|
|
|
const { getCookieName } = require("../index") |
|
|
|
|
|
const APP_PREFIX = DocumentTypes.APP + SEPARATOR |
|
|
|
|
|
|
|
|
module.exports = async (ctx, appId, version) => { |
|
|
module.exports = async (ctx, appId, version) => { |
|
|
const builderUser = { |
|
|
const builderUser = { |
|
|
@ -20,15 +23,18 @@ module.exports = async (ctx, appId, version) => { |
|
|
const expiry = new Date() |
|
|
const expiry = new Date() |
|
|
expiry.setDate(expiry.getDate() + 30) |
|
|
expiry.setDate(expiry.getDate() + 30) |
|
|
// set the builder token
|
|
|
// set the builder token
|
|
|
ctx.cookies.set("builder:token", token, { |
|
|
ctx.cookies.set(getCookieName(), 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
|
|
|
// need to clear all app tokens or else unable to use the app in the builder
|
|
|
let allDbNames = await CouchDB.allDbs() |
|
|
let allDbNames = await CouchDB.allDbs() |
|
|
allDbNames.map(dbName => {}) |
|
|
allDbNames.map(dbName => { |
|
|
ctx.cookies.set(`budibase:${appId}`, "", { |
|
|
if (dbName.startsWith(APP_PREFIX)) { |
|
|
overwrite: true, |
|
|
ctx.cookies.set(getCookieName(dbName), "", { |
|
|
|
|
|
overwrite: true, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|