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 是我想了解的部分,在解释您的答案时,您能否尝试说明为什么应该使用规定的方法来完成,以便我可以更好地判断哪个答案最适合我的要求。

4

1 回答 1

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

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

6) the temporary password must be single use

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

这种方法不涉及使值无效的批处理作业。

于 2010-11-21T16:54:32.323 回答