我创建了一个应用程序,用 bcrypt 存储您的密码,表单的输入类型是密码。我不明白为什么我会收到此警报?为什么我会收到“网站或应用程序上的数据泄露暴露了您的密码。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')
}
}
Run Code Online (Sandbox Code Playgroud)
服务器.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 …
Run Code Online (Sandbox Code Playgroud)