//[ValidateAntiForgeryToken] public ActionResult Index(Login_IndexVD vdForm) { //this.Validator(vdForm.Checkcode, "验证码", "Checkcode", null).ValidateCheckCode(CheckCodeKind.Login, true); //验证域名 string errorMsg = null; IAdminUserInfoService adminUserInfoService = null; AdminUserInfo adminUserInfo = null; if (vdForm.UserName.IsNullOrEmpty()) { errorMsg = "请填写账号!"; } else if (vdForm.Password.IsNullOrEmpty()) { errorMsg = "请填写密码!"; } else { if (Session["TryLoginTimes"] != null) { //TODO:验证码 } if (ModelState.IsValid) { adminUserInfoService = StructureMap.ObjectFactory.GetInstance <IAdminUserInfoService>(); adminUserInfo = adminUserInfoService.GetUserInfo(vdForm.UserName); if (adminUserInfo == null) { errorMsg = "账号或密码错误!错误代码:101。"; } //else if (userInfo.Locked) //{ // errorMsg = "账号已被锁定,无法登录。"; //} else if (adminUserInfoService.TryLogin(vdForm.UserName, vdForm.Password, true) == null) { errorMsg = "账号或密码错误!错误代码:102。"; } } } if (!errorMsg.IsNullOrEmpty() || !ModelState.IsValid) { var tryLoginTimes = 0; if (Session["TryLoginTimes"] != null) { tryLoginTimes = (int)Session["TryLoginTimes"]; } vdForm.ShowCheckCode = tryLoginTimes >= SiteConfig.TryLoginTimes; Session["TryLoginTimes"] = tryLoginTimes + 1; vdForm.MessagerList = new List <Messager>(); vdForm.MessagerList.Add(new Messager(Core.Enums.MessageType.error, errorMsg)); return(View(vdForm)); } Session["TryLoginTimes"] = null;//清空登录次数 LogUtility.AdminUserInfo.InfoFormat("用户登录成功:{0}", vdForm.UserName); Session["AdminLogin"] = "******"; if (vdForm.ReturnUrl.IsNullOrEmpty()) { return(RedirectToAction("Index", "Home")); } else { return(Redirect(vdForm.ReturnUrl.UrlDecode())); } }