Allow falsy values for force_change and Is_active in PUT user call (#95)

* allow falsy values

* apply review comments

Co-authored-by: eglehelms <e.helms@cognigy.com>
This commit is contained in:
EgleHandeglehelms authored and GitHub committed 2023-01-19 10:39:57 -05:00
1 parent 02bba9d981
commit 274377960e
1 file changed
+2 -2
+2 -2
View File
@@ -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]);