fix: /users/edit throw with empty edits

This commit is contained in:
Bobby 2022-08-23 15:09:47 +07:00
parent 2b6fd37ba1
commit ff7ec4aeaf
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09

View File

@ -355,6 +355,10 @@ self.editUser = async (req, res) => {
update.password = await bcrypt.hash(password, saltRounds)
}
if (!Object.keys(update).length) {
throw new ClientError('You are not editing any properties of this user.')
}
await utils.db.table('users')
.where('id', id)
.update(update)