必须更改临时密码
当用户登录遇到困难时,他们可以输入电子邮件地址来恢复密码。我的php发送一个临时密码(随机长数字,在数据库中加密)。但是,我希望他们被重定向到一个页面来更改密码(如果是临时密码)。
我如何知道它是否是临时密码?做到这一点+安全的最佳方法是什么?
谢谢
When a user is having difficulty signing in, they enter their email address to recover their password. My php sends a temporary password (random long number, encrypted in db). However, I want them to be redirected to a page to change their password if it's a temporary one.
How do I know if it's a temporary password or not? What's the best way to do it + secure?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种明显的方法是将其维护在
db
中,在这种情况下,您必须确保在用户成功更改密码后清除数据库。另一种方法是向用户发送一个秘密链接,供用户重置密码,而不是通过电子邮件发送在固定时间间隔内过期的密码(取决于数据的要求和敏感性)。在某些情况下,另一种方法是更安全的方法。One obvious way of doing this is to maintain it in the
db
, in this case you have to make sure that you clear the db once the user changes the password successfully. Another way of doing it is to send user a secret link for users to reset the password instead of emailing a password which expires in a fixed time interval (depending on the req. and sensitivity of the data). The other approach in some cases is a little more secured way.为数据库中的每个用户保留一个标志,指示他们的密码是否是临时的。
Keep a flag for each user in the database indicating if their password is temporary or not.