From 80c0d579e3d9ad0d1ffcc9e8ac17c81839f2dbac Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 22 May 2019 13:40:00 -0400 Subject: [PATCH] fix: #7593, unable to set account password if no password set --- src/user/profile.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/user/profile.js b/src/user/profile.js index cd42beb472..c34fefa58f 100644 --- a/src/user/profile.js +++ b/src/user/profile.js @@ -319,14 +319,20 @@ module.exports = function (User) { User.isPasswordValid(data.newPassword, next); }, function (next) { - User.isAdministrator(uid, next); + async.parallel({ + isAdmin: async.apply(User.isAdministrator, uid), + hasPassword: async.apply(User.hasPassword, uid), + }, next); }, - function (isAdmin, next) { - if (meta.config['password:disableEdit'] && !isAdmin) { + function (checks, next) { + if (meta.config['password:disableEdit'] && !checks.isAdmin) { return next(new Error('[[error:no-privileges]]')); } - if (isAdmin && parseInt(uid, 10) !== parseInt(data.uid, 10)) { + if ( + (checks.isAdmin && parseInt(uid, 10) !== parseInt(data.uid, 10)) || // Admins ok + (!checks.hasPassword && parseInt(uid, 10) === parseInt(data.uid, 10)) // Initial password set ok + ) { return next(null, true); }