发送电子邮件给用户的密码重置 [英] Send email to user for password reset
问题描述
的流程是:
- 用户输入电子邮件地址
- 后提交,电子邮件被发送到用户
- 电子邮件中将包括一个链接,将采取用户重置密码的页面。
现在,我该如何获取基于电子邮件地址,用户ID和加密呢?那么应该怎样链接?就像,我要的是获取用户ID,然后以某种方式进行加密,这样该链接不包含实际的ID和链接将用户带到一个网页,将文本框都重新设置密码。我只是困惑如何去了解它。
Now, how do I fetch user's ID based on the email address and encrypt it? Then what should link be? Like, what I want is fetch the User ID then encrypt it somehow so that the link doesn't contain the actual ID and that link will take the user to a page that will have textboxes to reset the password. I am just confused how to go about it.
此外,这是安全的方式?像这样重置密码?
Also is this the secure way? To reset a password like this?
推荐答案
我通常在数据库中创建新表:
I usually create a new table in the database:
PasswordresetRequest以下字段:
PasswordresetRequest with the following fields:
- 编号:的Guid - 标识密码重置请求
- ACCOUNTID:字符串 - 用户的用户名
- 创建:DATATIME - 当密码重置创建的时间戳
流程如下:
- 用户请求重置密码。
- 在PasswordresetRequest表创建一个新的记录。
- 的链接与密码请求id作为请求参数重设密码页面的电子邮件发送给用户。
- 在电子邮件用户点击链接,送他去重置密码的页面。
- 密码要求,如果牵强从数据库中请求参数。如果请求无法找到或并要求不大于例如年长12小时的形式psented用户,他可以输入新的密码$ P $。
在网站
这是pretty实现简单,对于大多数网站足够安全。
This is pretty simple to implement and is secure enough for most sites.
这篇关于发送电子邮件给用户的密码重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!