fix !!!!!!!!!!
This commit is contained in:
parent
854e9f5063
commit
12317413b8
@ -12,19 +12,9 @@ const {
|
|||||||
const hashPassword = async (pass = '') => {
|
const hashPassword = async (pass = '') => {
|
||||||
if (typeof pass !== 'string' || pass.trim().length === 0) return null
|
if (typeof pass !== 'string' || pass.trim().length === 0) return null
|
||||||
let saltRound = toInt(config.salt_round, 1, 1)
|
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) => {
|
let passHash = await new Promise((resolve, reject) => {
|
||||||
bcrypt.hash(pass, salt, (err, hash) => {
|
bcrypt.hash(pass, saltRound, (err, hash) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err)
|
reject(err)
|
||||||
return
|
return
|
||||||
@ -47,7 +37,6 @@ const comparePassword = async (password = '', hash = '') => {
|
|||||||
if (typeof hash !== 'string' || hash.trim().length === 0) return false
|
if (typeof hash !== 'string' || hash.trim().length === 0) return false
|
||||||
let check = await new Promise((resolve, reject) => {
|
let check = await new Promise((resolve, reject) => {
|
||||||
bcrypt.compare(password, hash, (err, res) => {
|
bcrypt.compare(password, hash, (err, res) => {
|
||||||
console.log('pass match :::: ', err, res)
|
|
||||||
if (err) {
|
if (err) {
|
||||||
resolve(false)
|
resolve(false)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user