我有一个与表单身份验证安全客户端一起使用的mvc应用程序,所有管理用户都是使用wcf协议在服务器端进行的。
并且在服务器站点中我将用户tocken保存在sessoin中
string token = Srv.ValidateUser(out isNewUser, model.UserName, model.Password, model.IdentityNumber);
if (!string.IsNullOrEmpty(token))
{
Session["Token"] = token;
}
使用此令牌我在服务中识别
以及表单身份验证中的用户名
FormsAuthentication.SetAuthCookie(model.UserName, false);
现在我不知道如何在首次登录后或密码过期后强制用户更改密码 我的配置是:
<system.web>
<sessionState mode="InProc" cookieless="true" timeout="20" />
<authentication mode="Forms">
<forms path="/" loginUrl="~/Account/Login" />
</authentication>
<authorization>
<allow users="*" />
<deny users="?" />
</authorization>
<identity impersonate="true" />
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
任何人都可以帮助我吗?
答案 0 :(得分:2)
在您的登录发布操作中,您可以像这样检查LastPasswordChangedDate:
var currentUser = Membership.GetUser(model.Email);
if (currentUser != null)
{
if (currentUser.LastPasswordChangedDate == currentUser.CreationDate)
{
// User has not changed password since created.
return RedirectPermanent("Login/?userName=" + model.Email);
}
}