fix pass match

This commit is contained in:
Jay 2018-08-23 20:20:35 +08:00
parent 3b3efe5791
commit dc14d9cbf5

View File

@ -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)