From dc14d9cbf5cce8fd1be568f3a9a2c5cea2bce949 Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 23 Aug 2018 20:20:35 +0800 Subject: [PATCH] fix pass match --- libs/tools/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/tools/index.js b/libs/tools/index.js index 06fe10d..cfd7b37 100644 --- a/libs/tools/index.js +++ b/libs/tools/index.js @@ -43,12 +43,12 @@ const hashPassword = async (pass = '') => { * @return {boolean} */ const comparePassword = async (password = '', hash = '') => { - if (typeof password !== 'string' || password.trim().length === 0) return null - if (typeof hash !== 'string' || hash.trim().length === 0) return null + if (typeof password !== 'string' || password.trim().length === 0) return false + if (typeof hash !== 'string' || hash.trim().length === 0) return false let check = new Promise((resolve, reject) => { bcrypt.compare(password, hash, (err, res) => { if (err) { - reject(err) + resolve(false) return } resolve(res)