public JsonResult Login(LoginModel model) { var result = new BaseResponse(); if (string.IsNullOrEmpty(model.UserName)) { result.SetFail("请输入用户名"); return(Json(result)); } if (string.IsNullOrEmpty(model.Password)) { result.SetFail("请输入密码"); return(Json(result)); } if (string.IsNullOrEmpty(model.VidateCode)) { result.SetFail("请输入验证码"); return(Json(result)); } if (ImageCodeHelper.GetImageCode() == null) { result.SetFail("验证码已过期,请刷新验证码"); return(Json(result)); } else { if (!ImageCodeHelper.ValidateImageCode(model.VidateCode.ToUpper())) { result.SetFail("验证码错误"); return(Json(result)); } } // API登录逻辑 // 登录成功 UserInfo userInfo = new UserInfo(); userInfo.UserId = Guid.NewGuid().ToString(); userInfo.UserName = "******"; AuthorizeProvider.StoreAuthorize(userInfo, HttpContext); result.SetSuccess("登录成功"); return(Json(result)); }
public ActionResult Logout() { AuthorizeProvider.RemoveAuthorize(HttpContext); return(RedirectToAction("Index", "Account")); }