Skip to content

Node.js based forum software built for the modern web

add brute-force protection for change password and email actions

Julian Lam7558046e7576
diff --git a/src/user/password.js b/src/user/password.js
index d644fd2e8f..bf39d029d0 100644
--- a/src/user/password.js
+++ b/src/user/password.js
@@ -33,7 +33,16 @@ module.exports = function (User) {
function (next) {
Password.compare(password, hashedPassword, next);
},
- ], callback);
+ ], function (err, ok) {
+ if (err) {
+ return callback(err);
+ }
+
+ // Delay return for incorrect current password
+ setTimeout(function () {
+ callback(null, ok);
+ }, ok ? 0 : 2500);
+ });
};
User.hasPassword = function (uid, callback) {