60天后如何设置用户更改密码 [英] How To set The User To Change His Password After 60 days

查看:112
本文介绍了60天后如何设置用户更改密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

这里我正在做注册模块我想每60天更改一次密码。6天后用户无法登录。如果用户更改密码则只有用户将登录。我可以在mvc5中做什么。

hi to all,
Here i'm doing register module i want to change password for every 60 days.After 6 days user cannot be login.If the user change the password then only the user will be login.how can i do in mvc5.

推荐答案

您的问题不明确,您希望在 6天或60天后 ????



您必须设置一个名称为 UpdatedAt(DateTime)在您的数据库表中更新密码。

登录时您必须检查更新日期和当前日期之间的差异是否大于6或60,而不是必须显示消息,您必须更改密码



您可以通过此查询获得差异



Your question is not clear ,you want it after 6 days or 60 days????

You have to set one field having name UpdatedAt(DateTime) in your database table in which password is updated.
at a time of login you have to check if the difference between updated date and current date is greater than 6 or 60 as you want than you have to show message that you have to change password

you can get difference by this query

select datediff(day,updateAt,GETDATE()) AS TimeDiff


继续What What rav建议,我建议在用户表中添加像[PasswordChangeDate]这样的显式字段,因为在标准设计中,表通常有UpdatedAt字段,如果User表中有更改,则必须更新。 PasswordChangeField只会在用户更改密码时更新。
In continuation of What Nirav has suggested, i would suggest to add an explicit field like [PasswordChangeDate] in the User Table as in standard design a table usually have UpdatedAt field which necessarily gets updated if there is a change in the User table. PasswordChangeField will only get updated when a user change password.


您只需要在存储密码更改的最后日期的表中使用日期字段说lastUpdate。每次用户登录时,检查当前日期与他的lastUpdate,

1.如果差异是< 60天,让他通过。

2.如果差异是> = 60天但是<= 66天,提示他更改密码但继续允许他登录,

3.否则,如果是> 66天,拒绝任何登录,直到他更改密码。
You just need a date field say lastUpdate in a table that stored the last date of password change. Every time a user logs in, check the current date against his lastUpdate,
1. if the difference is < 60 days, let him through.
2. if the difference is >= 60 days but <= 66 days, prompt him to change password but continue to allow him to log in,
3. else if it is > 66 days, reject any log in until he changes his password.


这篇关于60天后如何设置用户更改密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆