Skip to content

Node.js based forum software built for the modern web

fix: #7593, unable to set account password if no password set

Julian Lam80c0d579e3d9
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);
}