Handle 2fa fields in userdb code

This commit is contained in:
Johannes Zellner
2018-04-25 16:40:17 +02:00
parent 9e66adb6d0
commit 0167f83d4a

View File

@@ -23,11 +23,13 @@ var assert = require('assert'),
debug = require('debug')('box:userdb'),
DatabaseError = require('./databaseerror');
var USERS_FIELDS = [ 'id', 'username', 'email', 'fallbackEmail', 'password', 'salt', 'createdAt', 'modifiedAt', 'resetToken', 'displayName' ].join(',');
var USERS_FIELDS = [ 'id', 'username', 'email', 'fallbackEmail', 'password', 'salt', 'createdAt', 'modifiedAt', 'resetToken', 'displayName', 'twoFactorAuthenticationEnabled', 'twoFactorAuthenticationSecret' ].join(',');
function postProcess(result) {
assert.strictEqual(typeof result, 'object');
result.twoFactorAuthenticationEnabled = !!result.twoFactorAuthenticationEnabled;
return result;
}
@@ -209,6 +211,9 @@ function update(userId, user, callback) {
} else if (k === 'fallbackEmail') {
assert.strictEqual(typeof user.fallbackEmail, 'string');
args.push(user.fallbackEmail);
} else if (k === 'twoFactorAuthenticationEnabled') {
assert.strictEqual(typeof user.twoFactorAuthenticationEnabled, 'boolean');
args.push(user.twoFactorAuthenticationEnabled ? 1 : 0);
} else {
args.push(user[k]);
}