Merge branch 'master' into release

This commit is contained in:
Jay 2018-08-23 20:40:36 +08:00
commit a54cb680fa

View File

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