使用Forms身份验证首次登录asp.net mvc后强制用户更改密码

编程入门 行业动态 更新时间:2024-10-28 06:22:07
本文介绍了使用Forms身份验证首次登录asp mvc后强制用户更改密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个与表单身份验证安全客户端一起使用的mvc应用程序,所有管理用户都是在服务器端使用wcf协议制作的. 并且在服务器站点中,我将用户tocken保存在sessoin中

I'm have a mvc app that use with form authentication security client and all the manage user's is made in server side with wcf protocol. and in the server site I'm saving the user tocken in the sessoin

string token = Srv.ValidateUser(out isNewUser, model.UserName, model.Password, model.IdentityNumber); if (!string.IsNullOrEmpty(token)) { Session["Token"] = token; }

使用此令牌可以在服务中标识 和用户名,形式为认证

with this token I Identifies in the services and the user name in the form authentication

FormsAuthentication.SetAuthCookie(model.UserName, false);

现在我不知道如何在首次登录后或密码过期后强制用户更改密码. 我的配置是:

and now I dont know how to force user change password after first login or after password expired. My config is:

<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>

有人可以帮助我吗?

推荐答案

在您的登录后操作中,您可以像这样检查LastPasswordChangedDate:

In your Login post action, you can check LastPasswordChangedDate like so:

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); } }

更多推荐

使用Forms身份验证首次登录asp.net mvc后强制用户更改密码

本文发布于:2023-07-14 17:49:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1106043.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:首次   身份验证   密码   用户   Forms

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!