From 12317413b8f4b9c4eb5f6f9fc2094ba16ec8e62f Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 23 Aug 2018 20:40:19 +0800 Subject: [PATCH] fix !!!!!!!!!! --- libs/tools/index.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) 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