From 0c5571084562a1f582d6daf1ec369041f79a24ea Mon Sep 17 00:00:00 2001 From: Abraham Ingersoll <586805+aberoham@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:45:43 +0530 Subject: [PATCH] user: PUT accepts current_password user.PUT rejects a current_password field, so the api answers 400 to a password change that includes it. It takes any non-empty string, as session login does. --- CHANGELOG.md | 2 ++ lib/user.js | 1 + lib/user.test.js | 8 ++++++++ 3 files changed, 11 insertions(+) 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))