From ab45e06edb7474b01b7ebadd816040c1e74bd978 Mon Sep 17 00:00:00 2001 From: Dean Date: Tue, 7 Mar 2023 16:17:29 +0000 Subject: [PATCH] Review updates --- packages/worker/src/api/controllers/global/self.ts | 7 ++----- packages/worker/src/api/routes/validation/users.ts | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/worker/src/api/controllers/global/self.ts b/packages/worker/src/api/controllers/global/self.ts index 75a1b89a75..2e7044da37 100644 --- a/packages/worker/src/api/controllers/global/self.ts +++ b/packages/worker/src/api/controllers/global/self.ts @@ -124,11 +124,8 @@ export async function updateSelf( ) { const body = ctx.request.body - const update: UpdateSelf = {} - for (let [key, value] of Object.entries(body)) { - if (value) { - update[key as keyof UpdateSelf] = value - } + const update: UpdateSelf = { + ...body, } const user = await userSdk.updateSelf(ctx.user._id!, update) diff --git a/packages/worker/src/api/routes/validation/users.ts b/packages/worker/src/api/routes/validation/users.ts index bce1cf582b..30a3d67434 100644 --- a/packages/worker/src/api/routes/validation/users.ts +++ b/packages/worker/src/api/routes/validation/users.ts @@ -19,11 +19,11 @@ let schema: any = { export const buildSelfSaveValidation = () => { schema = { - password: Joi.string().allow(null, ""), + password: Joi.string().optional(), forceResetPassword: Joi.boolean().optional(), - firstName: Joi.string().allow(null, ""), - lastName: Joi.string().allow(null, ""), - onboardedAt: Joi.string().allow(null, ""), + firstName: Joi.string().allow("").optional(), + lastName: Joi.string().allow("").optional(), + onboardedAt: Joi.string().optional(), } return auth.joiValidator.body(Joi.object(schema).required().unknown(false)) }