From ff231b0095ccefda0f15c6bac48b74fd2b47343a Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 19 Mar 2024 13:30:42 +0000 Subject: [PATCH] Make password optional --- packages/backend-core/src/users/db.ts | 4 ++-- packages/types/src/api/web/user.ts | 2 +- packages/worker/src/api/routes/global/users.ts | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/backend-core/src/users/db.ts b/packages/backend-core/src/users/db.ts index 136cb4b8ad..04d3264e6f 100644 --- a/packages/backend-core/src/users/db.ts +++ b/packages/backend-core/src/users/db.ts @@ -500,13 +500,13 @@ export class UserDB { static async createAdminUser( email: string, - password: string, tenantId: string, + password?: string, opts?: CreateAdminUserOpts ) { const user: User = { email: email, - password: password, + password, createdAt: Date.now(), roles: {}, builder: { diff --git a/packages/types/src/api/web/user.ts b/packages/types/src/api/web/user.ts index 0de42622e6..d68d687dcb 100644 --- a/packages/types/src/api/web/user.ts +++ b/packages/types/src/api/web/user.ts @@ -63,7 +63,7 @@ export interface SearchUsersRequest { export interface CreateAdminUserRequest { email: string - password: string + password?: string tenantId: string ssoId?: string } diff --git a/packages/worker/src/api/routes/global/users.ts b/packages/worker/src/api/routes/global/users.ts index 3c9cfd2f41..6b9291b88b 100644 --- a/packages/worker/src/api/routes/global/users.ts +++ b/packages/worker/src/api/routes/global/users.ts @@ -7,12 +7,13 @@ import { users } from "../validation" import * as selfController from "../../controllers/global/self" const router: Router = new Router() +const OPTIONAL_STRING = Joi.string().optional().allow(null).allow("") function buildAdminInitValidation() { return auth.joiValidator.body( Joi.object({ email: Joi.string().required(), - password: Joi.string(), + password: OPTIONAL_STRING, tenantId: Joi.string().required(), ssoId: Joi.string(), })