sal*_*nch 9 rest google-chrome node.js reactjs axios
我创建了一个应用程序,用 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 => {
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)
})
Run Code Online (Sandbox Code Playgroud)
})
小智 14
代码显示正常。如果您使用的是谷歌浏览器,它有一项功能,可以在您使用的密码之前被泄露时发出警告。因此,如果您使用通用密码进行测试,则可能会发生这种情况。如果这是生产,那么您应该按照警告指示更新密码。
消费者事务文章链接:如果用户的密码在数据泄露中暴露,新版 Chrome 会警告用户
归档时间: |
|
查看次数: |
13887 次 |
最近记录: |