Merge branch 'master' of github.com:Budibase/budibase into new-datepicker
This commit is contained in:
commit
725eacec97
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "2.22.16",
|
||||
"version": "2.22.17",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/*",
|
||||
|
|
|
@ -45,6 +45,7 @@ type GroupFns = {
|
|||
getGroupBuilderAppIds: GroupBuildersFn
|
||||
}
|
||||
type CreateAdminUserOpts = {
|
||||
password?: string
|
||||
ssoId?: string
|
||||
hashPassword?: boolean
|
||||
requirePassword?: boolean
|
||||
|
@ -501,9 +502,9 @@ export class UserDB {
|
|||
static async createAdminUser(
|
||||
email: string,
|
||||
tenantId: string,
|
||||
password?: string,
|
||||
opts?: CreateAdminUserOpts
|
||||
) {
|
||||
const password = opts?.password
|
||||
const user: User = {
|
||||
email: email,
|
||||
password,
|
||||
|
|
|
@ -21,7 +21,7 @@ async function start() {
|
|||
app = koa.app
|
||||
server = koa.server
|
||||
// startup includes automation runner - if enabled
|
||||
await startup(app, server)
|
||||
await startup({ app, server })
|
||||
}
|
||||
|
||||
start().catch(err => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import env from "./environment"
|
||||
import * as redis from "./utilities/redis"
|
||||
import { generateApiKey, getChecklist } from "./utilities/workerRequests"
|
||||
import env from "../environment"
|
||||
import * as redis from "../utilities/redis"
|
||||
import { generateApiKey, getChecklist } from "../utilities/workerRequests"
|
||||
import {
|
||||
events,
|
||||
installation,
|
||||
|
@ -9,22 +9,22 @@ import {
|
|||
users,
|
||||
cache,
|
||||
} from "@budibase/backend-core"
|
||||
import fs from "fs"
|
||||
import { watch } from "./watch"
|
||||
import * as automations from "./automations"
|
||||
import * as fileSystem from "./utilities/fileSystem"
|
||||
import { default as eventEmitter, init as eventInit } from "./events"
|
||||
import * as migrations from "./migrations"
|
||||
import * as bullboard from "./automations/bullboard"
|
||||
import { watch } from "../watch"
|
||||
import * as automations from "../automations"
|
||||
import * as fileSystem from "../utilities/fileSystem"
|
||||
import { default as eventEmitter, init as eventInit } from "../events"
|
||||
import * as migrations from "../migrations"
|
||||
import * as bullboard from "../automations/bullboard"
|
||||
import * as pro from "@budibase/pro"
|
||||
import * as api from "./api"
|
||||
import sdk from "./sdk"
|
||||
import { initialise as initialiseWebsockets } from "./websockets"
|
||||
import { automationsEnabled, printFeatures } from "./features"
|
||||
import * as api from "../api"
|
||||
import sdk from "../sdk"
|
||||
import { initialise as initialiseWebsockets } from "../websockets"
|
||||
import { automationsEnabled, printFeatures } from "../features"
|
||||
import * as jsRunner from "../jsRunner"
|
||||
import Koa from "koa"
|
||||
import { Server } from "http"
|
||||
import { AddressInfo } from "net"
|
||||
import * as jsRunner from "./jsRunner"
|
||||
import fs from "fs"
|
||||
|
||||
let STARTUP_RAN = false
|
||||
|
||||
|
@ -61,8 +61,11 @@ function shutdown(server?: Server) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function startup(app?: Koa, server?: Server) {
|
||||
if (STARTUP_RAN) {
|
||||
export async function startup(
|
||||
opts: { app?: Koa; server?: Server; rerun?: boolean } = {}
|
||||
) {
|
||||
const { app, server, rerun } = opts
|
||||
if (STARTUP_RAN && !rerun) {
|
||||
return
|
||||
}
|
||||
printFeatures()
|
||||
|
@ -139,9 +142,9 @@ export async function startup(app?: Koa, server?: Server) {
|
|||
try {
|
||||
const user = await users.UserDB.createAdminUser(
|
||||
bbAdminEmail,
|
||||
bbAdminPassword,
|
||||
tenantId,
|
||||
{
|
||||
password: bbAdminPassword,
|
||||
hashPassword: true,
|
||||
requirePassword: true,
|
||||
skipPasswordValidation: true,
|
|
@ -0,0 +1,34 @@
|
|||
import TestConfiguration from "../../tests/utilities/TestConfiguration"
|
||||
import { startup } from "../index"
|
||||
import { users, utils, tenancy } from "@budibase/backend-core"
|
||||
|
||||
describe("check BB_ADMIN environment variables", () => {
|
||||
const config = new TestConfiguration()
|
||||
beforeAll(async () => {
|
||||
await config.init()
|
||||
})
|
||||
|
||||
it("should be able to create a user with the BB_ADMIN environment variables", async () => {
|
||||
const EMAIL = "budibase@budibase.com",
|
||||
PASSWORD = "budibase"
|
||||
await tenancy.doInTenant(tenancy.DEFAULT_TENANT_ID, async () => {
|
||||
await config.withEnv(
|
||||
{
|
||||
BB_ADMIN_USER_EMAIL: EMAIL,
|
||||
BB_ADMIN_USER_PASSWORD: PASSWORD,
|
||||
MULTI_TENANCY: "0",
|
||||
SELF_HOSTED: "1",
|
||||
},
|
||||
async () => {
|
||||
await startup({ rerun: true })
|
||||
const user = await users.getGlobalUserByEmail(EMAIL, {
|
||||
cleanup: false,
|
||||
})
|
||||
expect(user).toBeDefined()
|
||||
expect(user?.password).toBeDefined()
|
||||
expect(await utils.compare(PASSWORD, user?.password!)).toEqual(true)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
|
@ -146,16 +146,12 @@ export const adminUser = async (
|
|||
}
|
||||
|
||||
try {
|
||||
const finalUser = await userSdk.db.createAdminUser(
|
||||
email,
|
||||
tenantId,
|
||||
const finalUser = await userSdk.db.createAdminUser(email, tenantId, {
|
||||
password,
|
||||
{
|
||||
ssoId,
|
||||
hashPassword,
|
||||
requirePassword,
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
// events
|
||||
let account: CloudAccount | undefined
|
||||
|
|
Loading…
Reference in New Issue