Simplify the password change logic

We now can use verifyPassword and this makes
user.changePassword() route obsolete
This commit is contained in:
Johannes Zellner
2016-04-17 19:17:01 +02:00
parent 87dcf42c7e
commit 18f3733d6e
5 changed files with 26 additions and 64 deletions

View File

@@ -14,7 +14,6 @@ exports = module.exports = {
getAllAdmins: getAllAdmins,
resetPasswordByIdentifier: resetPasswordByIdentifier,
setPassword: setPassword,
changePassword: changePassword,
update: updateUser,
createOwner: createOwner,
getOwner: getOwner,
@@ -421,22 +420,6 @@ function setPassword(userId, newPassword, callback) {
});
}
function changePassword(username, oldPassword, newPassword, callback) {
assert.strictEqual(typeof username, 'string');
assert.strictEqual(typeof oldPassword, 'string');
assert.strictEqual(typeof newPassword, 'string');
assert.strictEqual(typeof callback, 'function');
var error = validatePassword(newPassword);
if (error) return callback(new UserError(UserError.BAD_PASSWORD, error.message));
verifyWithUsername(username.toLowerCase(), oldPassword, function (error, user) {
if (error) return callback(error);
setPassword(user.id, newPassword, callback);
});
}
function createOwner(username, password, email, displayName, callback) {
assert.strictEqual(typeof username, 'string');
assert.strictEqual(typeof password, 'string');