I am using ASP.NET membership for the authentication of my web app. This worked great for me. I now have to implement password expiration.
If the password has expired th
I used the code from above and only slightly modified it to implement in Asp.NET (4.5) MVC5 using the .NET Identity Provider. Just leaving it here for the next guy/gal :)
void Application_PostAuthenticateRequest(object sender, EventArgs e)
{
if (this.User.Identity.IsAuthenticated)
{
WisewomanDBContext db = new WisewomanDBContext();
// get user
var userId = User.Identity.GetUserId();
ApplicationUser user = db.Users.Find(userId);
// has their password expired?
if (user != null && user.PasswordExpires <= DateTime.Now.Date
&& !Request.Path.EndsWith("/Manage/ChangePassword"))
{
Response.Redirect("~/Manage/ChangePassword");
}
db.Dispose();
}
}