mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: improper targetUid check during password change
This commit is contained in:
@@ -280,13 +280,18 @@ module.exports = function (User) {
|
|||||||
}
|
}
|
||||||
let isAdminOrPasswordMatch = false;
|
let isAdminOrPasswordMatch = false;
|
||||||
const isSelf = parseInt(uid, 10) === parseInt(data.uid, 10);
|
const isSelf = parseInt(uid, 10) === parseInt(data.uid, 10);
|
||||||
|
|
||||||
|
if (!isAdmin && !isSelf) {
|
||||||
|
throw new Error('[[user:change_password_error_privileges]]');
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(isAdmin && !isSelf) || // Admins ok
|
(isAdmin && !isSelf) || // Admins ok
|
||||||
(!hasPassword && isSelf) // Initial password set ok
|
(!hasPassword && isSelf) // Initial password set ok
|
||||||
) {
|
) {
|
||||||
isAdminOrPasswordMatch = true;
|
isAdminOrPasswordMatch = true;
|
||||||
} else {
|
} else {
|
||||||
isAdminOrPasswordMatch = await User.isPasswordCorrect(uid, data.currentPassword, data.ip);
|
isAdminOrPasswordMatch = await User.isPasswordCorrect(data.uid, data.currentPassword, data.ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isAdminOrPasswordMatch) {
|
if (!isAdminOrPasswordMatch) {
|
||||||
|
|||||||
Reference in New Issue
Block a user