Skip to content

Node.js based forum software built for the modern web

always pass strings to bcrypt compare

Barış Soner Uşaklı870bb87b0858
diff --git a/src/bcrypt.js b/src/bcrypt.js
index 40a493e75d..8cce80372e 100644
--- a/src/bcrypt.js
+++ b/src/bcrypt.js
@@ -9,7 +9,7 @@ process.on('message', function (msg) {
if (msg.type === 'hash') {
hashPassword(msg.password, msg.rounds);
} else if (msg.type === 'compare') {
- bcrypt.compare(msg.password, msg.hash, done);
+ bcrypt.compare(String(msg.password || ''), String(msg.hash || ''), done);
}
});
diff --git a/src/password.js b/src/password.js
index 816e357d12..5405941fff 100644
--- a/src/password.js
+++ b/src/password.js
@@ -9,6 +9,9 @@
};
module.compare = function (password, hash, callback) {
+ if (!hash || !password) {
+ return setImmediate(callback, null, false);
+ }
forkChild({ type: 'compare', password: password, hash: hash }, callback);
};