From 39848a25a8e7f958515502e12f2d010e5ac6a0ee Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 26 Jul 2018 15:35:41 -0700 Subject: [PATCH] Refactor a bit --- src/userdb.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/userdb.js b/src/userdb.js index 999f129ce..441ad570c 100644 --- a/src/userdb.js +++ b/src/userdb.js @@ -207,15 +207,12 @@ function update(userId, user, callback) { if (k === 'username') { assert(user.username === null || typeof user.username === 'string'); args.push(user.username); - } else if (k === 'email') { - assert.strictEqual(typeof user.email, 'string'); - args.push(user.email); - } else if (k === 'fallbackEmail') { - assert.strictEqual(typeof user.fallbackEmail, 'string'); - args.push(user.fallbackEmail); + } else if (k === 'email' || k === 'fallbackEmail') { + assert.strictEqual(typeof user[k], 'string'); + args.push(user[k]); } else if (k === 'twoFactorAuthenticationEnabled') { - assert.strictEqual(typeof user.twoFactorAuthenticationEnabled, 'boolean'); - args.push(user.twoFactorAuthenticationEnabled ? 1 : 0); + assert.strictEqual(typeof user[k], 'boolean'); + args.push(user[k] ? 1 : 0); } else { args.push(user[k]); }