mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #7593, unable to set account password if no password set
This commit is contained in:
@@ -319,14 +319,20 @@ module.exports = function (User) {
|
|||||||
User.isPasswordValid(data.newPassword, next);
|
User.isPasswordValid(data.newPassword, next);
|
||||||
},
|
},
|
||||||
function (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) {
|
function (checks, next) {
|
||||||
if (meta.config['password:disableEdit'] && !isAdmin) {
|
if (meta.config['password:disableEdit'] && !checks.isAdmin) {
|
||||||
return next(new Error('[[error:no-privileges]]'));
|
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);
|
return next(null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user