Fixing some issues with org not being correctly detected.
This commit is contained in:
parent
1b40740709
commit
615053f201
|
@ -33,6 +33,7 @@ function finalise(ctx, { authenticated, user, internal, version } = {}) {
|
|||
module.exports = (noAuthPatterns = [], opts) => {
|
||||
const noAuthOptions = noAuthPatterns ? buildNoAuthRegex(noAuthPatterns) : []
|
||||
return async (ctx, next) => {
|
||||
let publicEndpoint = false
|
||||
const version = ctx.request.headers[Headers.API_VER]
|
||||
// the path is not authenticated
|
||||
const found = noAuthOptions.find(({ regex, method }) => {
|
||||
|
@ -42,7 +43,7 @@ module.exports = (noAuthPatterns = [], opts) => {
|
|||
)
|
||||
})
|
||||
if (found != null) {
|
||||
return next()
|
||||
publicEndpoint = true
|
||||
}
|
||||
try {
|
||||
// check the actual user is authenticated first
|
||||
|
@ -93,7 +94,7 @@ module.exports = (noAuthPatterns = [], opts) => {
|
|||
return next()
|
||||
} catch (err) {
|
||||
// allow configuring for public access
|
||||
if (opts && opts.publicAllowed) {
|
||||
if ((opts && opts.publicAllowed) || publicEndpoint) {
|
||||
finalise(ctx, { authenticated: false, version })
|
||||
} else {
|
||||
ctx.throw(err.status || 403, err)
|
||||
|
|
|
@ -16,9 +16,13 @@
|
|||
|
||||
// Force creation of an admin user if one doesn't exist
|
||||
$: {
|
||||
console.log(`loaded: ${loaded}`)
|
||||
console.log(`tenancy: ${multiTenancyEnabled}`)
|
||||
console.log(`tenant set: ${tenantSet}`)
|
||||
if (loaded && multiTenancyEnabled && !tenantSet) {
|
||||
$redirect("./auth/org")
|
||||
} else if (loaded && !hasAdminUser) {
|
||||
|
||||
$redirect("./admin")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,27 +33,29 @@ async function init() {
|
|||
fs.writeFileSync(envoyOutputPath, processStringSync(contents, config))
|
||||
|
||||
const envFilePath = path.join(process.cwd(), ".env")
|
||||
const envFileJson = {
|
||||
PORT: 4001,
|
||||
MINIO_URL: "http://localhost:10000/",
|
||||
COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/",
|
||||
REDIS_URL: "localhost:6379",
|
||||
WORKER_URL: "http://localhost:4002",
|
||||
INTERNAL_API_KEY: "budibase",
|
||||
JWT_SECRET: "testsecret",
|
||||
REDIS_PASSWORD: "budibase",
|
||||
MINIO_ACCESS_KEY: "budibase",
|
||||
MINIO_SECRET_KEY: "budibase",
|
||||
COUCH_DB_PASSWORD: "budibase",
|
||||
COUCH_DB_USER: "budibase",
|
||||
SELF_HOSTED: 1,
|
||||
MULTI_TENANCY: "",
|
||||
if (!fs.existsSync(envFilePath)) {
|
||||
const envFileJson = {
|
||||
PORT: 4001,
|
||||
MINIO_URL: "http://localhost:10000/",
|
||||
COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/",
|
||||
REDIS_URL: "localhost:6379",
|
||||
WORKER_URL: "http://localhost:4002",
|
||||
INTERNAL_API_KEY: "budibase",
|
||||
JWT_SECRET: "testsecret",
|
||||
REDIS_PASSWORD: "budibase",
|
||||
MINIO_ACCESS_KEY: "budibase",
|
||||
MINIO_SECRET_KEY: "budibase",
|
||||
COUCH_DB_PASSWORD: "budibase",
|
||||
COUCH_DB_USER: "budibase",
|
||||
SELF_HOSTED: 1,
|
||||
MULTI_TENANCY: "",
|
||||
}
|
||||
let envFile = ""
|
||||
Object.keys(envFileJson).forEach(key => {
|
||||
envFile += `${key}=${envFileJson[key]}\n`
|
||||
})
|
||||
fs.writeFileSync(envFilePath, envFile)
|
||||
}
|
||||
let envFile = ""
|
||||
Object.keys(envFileJson).forEach(key => {
|
||||
envFile += `${key}=${envFileJson[key]}\n`
|
||||
})
|
||||
fs.writeFileSync(envFilePath, envFile)
|
||||
}
|
||||
|
||||
async function up() {
|
||||
|
|
|
@ -4,7 +4,7 @@ const {
|
|||
getGlobalUserParams,
|
||||
getScopedFullConfig,
|
||||
getGlobalDBFromCtx,
|
||||
getGlobalDB,
|
||||
getTenantIdFromCtx,
|
||||
getAllApps,
|
||||
} = require("@budibase/auth/db")
|
||||
const { Configs } = require("../../../constants")
|
||||
|
@ -218,8 +218,8 @@ exports.destroy = async function (ctx) {
|
|||
}
|
||||
|
||||
exports.configChecklist = async function (ctx) {
|
||||
const tenantId = ctx.request.query.tenantId
|
||||
const db = tenantId ? getGlobalDB(tenantId) : getGlobalDBFromCtx(ctx)
|
||||
const tenantId = getTenantIdFromCtx(ctx)
|
||||
const db = getGlobalDBFromCtx(ctx)
|
||||
|
||||
try {
|
||||
// TODO: Watch get started video
|
||||
|
|
Loading…
Reference in New Issue