1
0
Fork 0
mirror of synced 2024-09-02 10:41:09 +12:00

Merge branch 'master' of github.com:Budibase/budibase into labday/sqs

This commit is contained in:
mike12345567 2024-04-05 16:36:36 +01:00
commit 5f44b98b7f
6 changed files with 64 additions and 30 deletions

View file

@ -1,5 +1,5 @@
{ {
"version": "2.22.16", "version": "2.22.17",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*", "packages/*",

View file

@ -45,6 +45,7 @@ type GroupFns = {
getGroupBuilderAppIds: GroupBuildersFn getGroupBuilderAppIds: GroupBuildersFn
} }
type CreateAdminUserOpts = { type CreateAdminUserOpts = {
password?: string
ssoId?: string ssoId?: string
hashPassword?: boolean hashPassword?: boolean
requirePassword?: boolean requirePassword?: boolean
@ -501,9 +502,9 @@ export class UserDB {
static async createAdminUser( static async createAdminUser(
email: string, email: string,
tenantId: string, tenantId: string,
password?: string,
opts?: CreateAdminUserOpts opts?: CreateAdminUserOpts
) { ) {
const password = opts?.password
const user: User = { const user: User = {
email: email, email: email,
password, password,

View file

@ -21,7 +21,7 @@ async function start() {
app = koa.app app = koa.app
server = koa.server server = koa.server
// startup includes automation runner - if enabled // startup includes automation runner - if enabled
await startup(app, server) await startup({ app, server })
} }
start().catch(err => { start().catch(err => {

View file

@ -1,6 +1,6 @@
import env from "./environment" import env from "../environment"
import * as redis from "./utilities/redis" import * as redis from "../utilities/redis"
import { generateApiKey, getChecklist } from "./utilities/workerRequests" import { generateApiKey, getChecklist } from "../utilities/workerRequests"
import { import {
events, events,
installation, installation,
@ -9,22 +9,22 @@ import {
users, users,
cache, cache,
} from "@budibase/backend-core" } from "@budibase/backend-core"
import fs from "fs" import { watch } from "../watch"
import { watch } from "./watch" import * as automations from "../automations"
import * as automations from "./automations" import * as fileSystem from "../utilities/fileSystem"
import * as fileSystem from "./utilities/fileSystem" import { default as eventEmitter, init as eventInit } from "../events"
import { default as eventEmitter, init as eventInit } from "./events" import * as migrations from "../migrations"
import * as migrations from "./migrations" import * as bullboard from "../automations/bullboard"
import * as bullboard from "./automations/bullboard"
import * as pro from "@budibase/pro" import * as pro from "@budibase/pro"
import * as api from "./api" import * as api from "../api"
import sdk from "./sdk" import sdk from "../sdk"
import { initialise as initialiseWebsockets } from "./websockets" import { initialise as initialiseWebsockets } from "../websockets"
import { automationsEnabled, printFeatures } from "./features" import { automationsEnabled, printFeatures } from "../features"
import * as jsRunner from "../jsRunner"
import Koa from "koa" import Koa from "koa"
import { Server } from "http" import { Server } from "http"
import { AddressInfo } from "net" import { AddressInfo } from "net"
import * as jsRunner from "./jsRunner" import fs from "fs"
let STARTUP_RAN = false let STARTUP_RAN = false
@ -66,8 +66,11 @@ function shutdown(server?: Server) {
} }
} }
export async function startup(app?: Koa, server?: Server) { export async function startup(
if (STARTUP_RAN) { opts: { app?: Koa; server?: Server; rerun?: boolean } = {}
) {
const { app, server, rerun } = opts
if (STARTUP_RAN && !rerun) {
return return
} }
printFeatures() printFeatures()
@ -144,9 +147,9 @@ export async function startup(app?: Koa, server?: Server) {
try { try {
const user = await users.UserDB.createAdminUser( const user = await users.UserDB.createAdminUser(
bbAdminEmail, bbAdminEmail,
bbAdminPassword,
tenantId, tenantId,
{ {
password: bbAdminPassword,
hashPassword: true, hashPassword: true,
requirePassword: true, requirePassword: true,
skipPasswordValidation: true, skipPasswordValidation: true,

View file

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

View file

@ -146,16 +146,12 @@ export const adminUser = async (
} }
try { try {
const finalUser = await userSdk.db.createAdminUser( const finalUser = await userSdk.db.createAdminUser(email, tenantId, {
email,
tenantId,
password, password,
{ ssoId,
ssoId, hashPassword,
hashPassword, requirePassword,
requirePassword, })
}
)
// events // events
let account: CloudAccount | undefined let account: CloudAccount | undefined