bcrypt.compare возвращает false - PullRequest
0 голосов
/ 16 апреля 2020

/ / это мой маршрут для входа в систему. Когда я отправляю запрос от почтальона, он возвращает 404. Но когда я console.log (isMatch). Он возвращает ложь. Пожалуйста, помогите мне в этом вопросе

 router.post('/login',async (req,res)=>{

    try{
            const user = await User.findByCredentials(req.body.email,req.body.password)
            console.log(user)
            res.send(user)
    }
    catch(e){
        res.status(404).send(e)
    }

})

//this is userShema

userSchema.statics.findByCredentials = async(email,password)=>{




const user = await User.findOne({email})
    if(!user){
        throw new Error('No user')
    }
    const isMatch = await bcrypt.compare( password ,user.password)
    console.log(isMatch)
    if(!isMatch){
        throw new Error('invalid')
    }
    console.log(Match)
    console.log(user)
     return user
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...