public JsonResult AjaxLogin(string name, string password) { var result = new Result(false); if (string.IsNullOrWhiteSpace(name)) { result.Message = "消息:用户名不能为空!"; } if (string.IsNullOrWhiteSpace(password)) { result.Message = "消息:密码不能为空!"; } MemoryCacheHelper.RemoveCacheAll(); if (!RbacPrincipal.Login(name, password)) { result.Message = "消息:用户或密码错误,请重新输入!!"; } else { result = new Result(true); var identity = LEnvironment.Principal as MyFormsPrincipal <MyUserDataPrincipal>; if (identity != null) { //if (identity.DepUserType == 2) //{ // result.Message = "../../" + LCL.MvcExtensions.PageFlowService.PageNodes.FindPageNode("LayoutHome1").Value; //} //else //{ result.Message = "../../" + LCL.MvcExtensions.PageFlowService.PageNodes.FindPageNode("LayoutHome").Value; // } } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Login(Account account) { //if (Session["ValidateCode"].ToString() != account.VerifyCode) //{ // ModelState.AddModelError("VerifyCode", "validate code is error"); // return View(); //} if (!ModelState.IsValid) { return(View()); } if (string.IsNullOrWhiteSpace(account.Name)) { ModelState.AddModelError("Name", "消息:用户名不能为空!"); return(View()); } if (string.IsNullOrWhiteSpace(account.Password)) { ModelState.AddModelError("Name", "消息:密码不能为空!"); return(View()); } MemoryCacheHelper.RemoveCacheAll(); if (!RbacPrincipal.Login(account.Name, account.Password)) { ModelState.AddModelError("Name", "消息:用户或密码错误,请重新输入!"); return(View()); } else { return(RedirectIndex()); } }