From 274377960ecf253895630211891ebc99e10e2200 Mon Sep 17 00:00:00 2001 From: EgleH Date: Thu, 19 Jan 2023 16:39:57 +0100 Subject: [PATCH] Allow falsy values for force_change and Is_active in PUT user call (#95) * allow falsy values * apply review comments Co-authored-by: eglehelms --- lib/routes/api/users.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/routes/api/users.js b/lib/routes/api/users.js index 901630c..665594b 100644 --- a/lib/routes/api/users.js +++ b/lib/routes/api/users.js @@ -305,12 +305,12 @@ router.put('/:user_sid', async(req, res) => { if (0 === r.changedRows) throw new Error('database update failed'); } - if (is_active) { + if (typeof is_active !== 'undefined') { const r = await promisePool.execute('UPDATE users SET is_active = ? WHERE user_sid = ?', [is_active, user_sid]); if (0 === r.changedRows) throw new Error('database update failed'); } - if (force_change) { + if (typeof force_change !== 'undefined') { const r = await promisePool.execute( 'UPDATE users SET force_change = ? WHERE user_sid = ?', [force_change, user_sid]);