I have a ASP.NET project using Identity. For Identity Configuration regarding passwords, the PasswordValidator
is being used. How do I expand the enforcement of password beyond what PasswordValidator
has currently (RequiredLength
, RequiredDigit
, etc.) to satisfy a requirement that asks for password expiration after N days?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
There is no such functionality builtin ASP.NET Identity 2. Easiest is to add a field on the user like LastPasswordChangedDate. And then check this field during each Authorization.
Adding on to @Rikard's answer...
I added
LastPasswordChangedDate
to myApplicationUser
model, like so:Add a static configuration setting to
AccountController
(you'll need this later on inLogin()
:Then, during
Login
, check to see if the user should reset password. This only checks after a successful login, as to not bug user too much.Make sure to update the
LastPasswordChangedDate
when the user successfully updates password, in ManageController, ChangePassword action: