diff --git a/CHANGELOG.md b/CHANGELOG.md index 160693f..fd65c7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Unreleased +- user: PUT accepts current_password + ### [1.0.1] - 2026-08-31 - zone: run 3 disabled validation cases (#33) diff --git a/lib/user.js b/lib/user.js index 1e31801..59b32cc 100644 --- a/lib/user.js +++ b/lib/user.js @@ -78,6 +78,7 @@ export const PUT = Joi.object({ username: username, email: email, password: password, + current_password: Joi.string().min(1), is_admin: Joi.boolean(), deleted: Joi.boolean(), inherit_group_permissions: Joi.boolean(), diff --git a/lib/user.test.js b/lib/user.test.js index 5ed2c73..4878467 100644 --- a/lib/user.test.js +++ b/lib/user.test.js @@ -24,6 +24,14 @@ describe('user', function () { assert.ok(schema.PUT.validate({ group_write: 'sometimes' }).error) }) + it('takes the current password with a new one in PUT', () => { + const payload = { password: 'This 1 Is Very 3#$@!in', current_password: 'weak' } + const { error, value } = schema.PUT.validate(payload) + assert.ifError(error) + assert.deepEqual(value, payload) + assert.ok(schema.PUT.validate({ ...payload, current_password: '' }).error) + }) + describe('v2', function () { it('accepts valid', () => { const testCase = JSON.parse(JSON.stringify(userV2))