Review updates
This commit is contained in:
parent
ec9e570ac2
commit
ab45e06edb
|
@ -124,11 +124,8 @@ export async function updateSelf(
|
||||||
) {
|
) {
|
||||||
const body = ctx.request.body
|
const body = ctx.request.body
|
||||||
|
|
||||||
const update: UpdateSelf = {}
|
const update: UpdateSelf = {
|
||||||
for (let [key, value] of Object.entries(body)) {
|
...body,
|
||||||
if (value) {
|
|
||||||
update[key as keyof UpdateSelf] = value
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await userSdk.updateSelf(ctx.user._id!, update)
|
const user = await userSdk.updateSelf(ctx.user._id!, update)
|
||||||
|
|
|
@ -19,11 +19,11 @@ let schema: any = {
|
||||||
|
|
||||||
export const buildSelfSaveValidation = () => {
|
export const buildSelfSaveValidation = () => {
|
||||||
schema = {
|
schema = {
|
||||||
password: Joi.string().allow(null, ""),
|
password: Joi.string().optional(),
|
||||||
forceResetPassword: Joi.boolean().optional(),
|
forceResetPassword: Joi.boolean().optional(),
|
||||||
firstName: Joi.string().allow(null, ""),
|
firstName: Joi.string().allow("").optional(),
|
||||||
lastName: Joi.string().allow(null, ""),
|
lastName: Joi.string().allow("").optional(),
|
||||||
onboardedAt: Joi.string().allow(null, ""),
|
onboardedAt: Joi.string().optional(),
|
||||||
}
|
}
|
||||||
return auth.joiValidator.body(Joi.object(schema).required().unknown(false))
|
return auth.joiValidator.body(Joi.object(schema).required().unknown(false))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue