I created an app, that stores your password with bcrypt, and the input type of the form is password. I don't understand why I am receiving this alert? Why am I getting "A data breach on a site or app exposed your password. Chrome recommends changing your password on "SITENAME" now."
axios.post(`/signup`, {
userBody: values.username,
passwordBody: values.password
}).then(response => console.log(response))
.then(response => history.push('/login'))
.catch(error => {
setErrors({
error: error.response.status
})
})
} else {
alert('cant be empty fields')
}
}
server.js
app.post('/signup', async (req, res) => {
const today = new Date();
const userData = {
username: req.body.userBody,
password: req.body.passwordBody,
created: today
};
User.findOne({
where: {
username: req.body.userBody
}
})
.then(user => {
if (!user) {
bcrypt.hash(req.body.passwordBody, 10, (err, hash) => {
userData.password = hash
User.create(userData)
.then(user => {
res.json({ status: user.username + " registered" })
})
.catch(err => {
res.send('error' + err)
})
})
}
else {
res.status(500).json({ message: 'message' })
console.log('User exists')
}
})
.catch(err => {
res.send('error' + err)
})
})