2010-11-21 63 views
1

我需要提供功能来重置我们的asp.net网站上的用户密码。考虑到我必须遵循的要求,我可以/应该采取什么方法来更改密码?

要完成此操作,用户必须提供他们注册的电子邮件地址,并且功能应重置已忘记的密码,这很容易。

棘手的部分是考虑到网站的会员模型(不使用标准的AspnetMembershipProviders),网站使用自己的系统来处理用户。

约我已经提供了和我必须遵循的要求,这是这个问题的支点:

1) User can enter email address to reset password 
2) the password that is sent to the email address provided 
3) the temporary password must be valid for no more than 24 hours 
4) the email will provide the link to allow them to enter the temporary password 
5) when they log in they must be prompted to reset to a permanent password 
6) the temporary password must be single use 

对于点3.同事使用SQL作业自动化的时间限制,但建议我不完全确定这将如何工作,或者如果这是最好的方法。

对于第6点,我正在考虑在登录时使用触发器来使临时密码无效,这样如果他们再次尝试,他们将不得不再次通过整个过程。

3和6是我想要的想法的部分,当解释你的答案时,你可以试着说明为什么应该使用规定的方法来完成,所以我可以更好地判断哪个答案最符合我的要求。

回答

2
3) the temporary password must be valid for no more than 24 hours 

这是我会做的。当人要求重置密码时,系统生成的密码将更新到数据库表中。此表格有LastModified列和IsSystemGeneratedPassword列,这两列将分别设置为then datetime和true。接下来,当用户尝试登录时,如果IsSystemGeneratedPassword为真,那么我会将LastModified与当前日期进行比较,并查找已用时间。如果超过限制(24小时内),则不允许登录。告诉用户他的临时密码到期并再次重定向到重置密码页面。

6) the temporary password must be single use 

当用户通过上述步骤3登录并能够成功登录,因为IsSystemGeneratedPassword是真实的,用户必须重定向,他们将其更改为自己选择的一个更改密码的页面。没有选择。当用户更改时,IsSystemGeneratedPassword将被设置为false。

此方法不涉及批处理作业以使值失效。

+0

谢谢 - 这样一个简单的方法来实现它,没有批次。 – 2010-11-21 17:01:58

相关问题