Click here to Skip to main content
15,897,291 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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.
Posted
Updated 1-Aug-14 22:03pm
v2

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

SQL
select datediff(day,updateAt,GETDATE()) AS TimeDiff
 
Share this answer
 
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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900