关于在asp.net mvc中实现忘记密码功能的一些问题
我想在 asp.net mvc 中实现忘记密码功能,允许用户重置密码,并在这方面有一些问题:
假设在允许用户重置密码之前,我想验证一些额外的内容信息,例如他们的名字和姓氏。默认情况下,此信息不存储在 aspnet_regsql 创建的表中。解决此类问题的建议方法是什么?我应该将此类信息存储在单独的表中,并使用表联接来验证,还是应该修改由 aspnet_regsql 生成的表的架构(如何?)以便我不必使用联接?我需要编写自定义提供程序还是没有必要?
我已经阅读过一些地方,例如这篇帖子,而不是通过电子邮件发送临时密码,另一种方法是通过电子邮件发送一个 URL,单击该 URL 后允许用户更改密码。这是怎么做到的?如何确保 URL 在 1 小时后过期?
I want to implement a forgot-password feature in asp.net mvc that allows users to reset their password, and have some questions in this regard:
Lets say that before allowing users to reset their password, I want to verify some extra information such as their first and last name. This info is not stored by default in the table created by aspnet_regsql. What is the recommended approach to address such issues? Should I store this kind of info in a separate table, and use table joins to verify OR should i modify the schema of the table generated by aspnet_regsql (how?) so that I don't have to use joins? Do I need to write a custom provider OR would that not be necessary?
I have read at places e.g. in this post that instead of emailing a temporary password, an alternative is to email a URL that when clicked allows users to change their password. How is this done? How to ensure that the URL expires after 1 hour?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以针对你提出的问题详细写出几个答案。有太多的细节无法详细介绍,但我会尽力抓住设计网站时牢记的要点。基本上,您可以(并且应该)与会员提供商合作,而不是绕过它。这需要一些工作,但可以使用提供程序和 ASP.NET MVC 完成以下所有操作。
如果我想到更多,我会扩展这个。
I could write at length several answers to the questions you pose. There are too many to get into implementation detail, but I'll try to hit the points that I've kept in mind when designing sites. Basically, you can (and should) work with the Membership provider instead of working around it. It's a bit of work but possible to do all of the following using the providers and ASP.NET MVC.
I'll expand this if I think of any more.
我不知道这是否是推荐的方法,但您可以像您提到的那样创建一个单独的表,然后实现您自己的会员资格提供商。这样,在重置密码时,您就可以实现所需的附加功能。
对于第二部分:
我将生成一个令牌,请在此处了解生成它的各种方法。您可以存储带有日期/时间的令牌,通过电子邮件将链接发送给用户,并将令牌作为 URL 的一部分,然后,一旦用户单击它,您就可以根据经过的时间来检查它。
I don't know if this is the recommended approach but you could create a separate table like you mentioned and then implement your own membership provider. That way on a password reset you can implement the additional functionality required.
For the second part:
I would generate a token, read about a variety of ways to generate it here. You can store the token with a date/time, email a link to the user with the token as part of the URL, then you'd be able to check it against the amount of elapsed time, once the users clicks on it.