我创建了一个应用程序,该应用程序使用bcrypt存储您的密码,并且表单的输入类型为password。我不明白为什么会收到此警报?我为什么会收到“网站或应用程序上的数据泄露暴露了您的密码。Chrome建议立即更改“SITENAME”上的密码。”
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',异步(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)
})
})
最佳答案
该代码似乎还可以。如果您使用的是Google Chrome浏览器,它具有一项功能,如果您先前使用的密码已被泄露,则会发出警告。因此,如果您使用通用密码进行测试,则可能会发生这种情况。如果这是正式产品,则应按警告指示更新密码。
Link to Consumer Affairs Article: New version of Chrome warns users if their password was exposed in a data breach
关于node.js - 我为什么现在要获得“ “A data breach on a site or app exposed your password. Chrome recommends changing your password on ” SITENAME”。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60470692/