Merge active flag into update route
This commit is contained in:
19
src/users.js
19
src/users.js
@@ -30,8 +30,6 @@ exports = module.exports = {
|
||||
enableTwoFactorAuthentication: enableTwoFactorAuthentication,
|
||||
disableTwoFactorAuthentication: disableTwoFactorAuthentication,
|
||||
|
||||
setActive: setActive,
|
||||
|
||||
count: count
|
||||
};
|
||||
|
||||
@@ -408,7 +406,7 @@ function updateUser(userId, data, auditSource, callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
var error;
|
||||
data = _.pick(data, 'email', 'fallbackEmail', 'displayName', 'username', 'admin');
|
||||
data = _.pick(data, 'email', 'fallbackEmail', 'displayName', 'username', 'admin', 'active');
|
||||
|
||||
if (_.isEmpty(data)) return callback();
|
||||
|
||||
@@ -447,7 +445,8 @@ function updateUser(userId, data, auditSource, callback) {
|
||||
eventlog.add(eventlog.ACTION_USER_UPDATE, auditSource, {
|
||||
userId: userId,
|
||||
user: removePrivateFields(result),
|
||||
adminStatusChanged: ((result.admin && !oldUser.admin) || (!result.admin && oldUser.admin))
|
||||
adminStatusChanged: ((result.admin && !oldUser.admin) || (!result.admin && oldUser.admin)),
|
||||
activeStatusChanged: ((result.active && !oldUser.active) || (!result.active && oldUser.active))
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -661,15 +660,3 @@ function disableTwoFactorAuthentication(userId, callback) {
|
||||
callback(null);
|
||||
});
|
||||
}
|
||||
|
||||
function setActive(userId, active, callback) {
|
||||
assert.strictEqual(typeof userId, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
userdb.update(userId, { active: active }, function (error) {
|
||||
if (error) return callback(new UsersError(UsersError.INTERNAL_ERROR, error));
|
||||
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UsersError(UsersError.NOT_FOUND, error));
|
||||
|
||||
callback(null);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user