diff --git a/server/password-hash.js b/server/password-hash.js index 468b2a352..df723b218 100644 --- a/server/password-hash.js +++ b/server/password-hash.js @@ -2,7 +2,7 @@ const passwordHashOld = require("password-hash"); const bcrypt = require("bcryptjs"); -const saltRounds = bcrypt.genSalt(); +const saltRounds = bcrypt.genSaltSync(); /** * Hash a password @@ -20,13 +20,12 @@ exports.generate = function (password) { * @returns {boolean} Does the password match the hash? */ exports.verify = function (password, hash) { - if (isSHA1(hash)) { - return passwordHashOld.verify(password, hash); - } - - return bcrypt.compareSync(password, hash); + let match; + match = isSHA1(hash) ? passwordHashOld.verify(password, hash) : bcrypt.compareSync(password, hash); + return match; }; + /** * Is the hash a SHA1 hash * @param {string} hash @@ -34,7 +33,7 @@ exports.verify = function (password, hash) { */ function isSHA1(hash) { return (typeof hash === "string" && hash.startsWith("sha1")); -} +}; /** * Does the hash need to be rehashed?