diff --git a/libs/tools/index.js b/libs/tools/index.js index 363d46e..3ad07ff 100644 --- a/libs/tools/index.js +++ b/libs/tools/index.js @@ -12,19 +12,9 @@ const { const hashPassword = async (pass = '') => { if (typeof pass !== 'string' || pass.trim().length === 0) return null let saltRound = toInt(config.salt_round, 1, 1) - // gen salt - let salt = await new Promise((resolve, reject) => { - bcrypt.genSalt(saltRound, (err, saltStr) => { - if (err) { - reject(err) - return - } - resolve(saltStr) - }) - }) - let passHash = new Promise((resolve, reject) => { - bcrypt.hash(pass, salt, (err, hash) => { + let passHash = await new Promise((resolve, reject) => { + bcrypt.hash(pass, saltRound, (err, hash) => { if (err) { reject(err) return @@ -47,7 +37,6 @@ const comparePassword = async (password = '', hash = '') => { if (typeof hash !== 'string' || hash.trim().length === 0) return false let check = await new Promise((resolve, reject) => { bcrypt.compare(password, hash, (err, res) => { - console.log('pass match :::: ', err, res) if (err) { resolve(false) return