public ActionResult Login(string username, string password, string verifyCode) { if (string.IsNullOrEmpty(username)) { return(Json(new AjaxResult { Status = "0", Msg = "账户名不能为空" })); } if (string.IsNullOrEmpty(password)) { return(Json(new AjaxResult { Status = "0", Msg = "密码不能为空" })); } if (string.IsNullOrEmpty(verifyCode)) { return(Json(new AjaxResult { Status = "0", Msg = "验证码不能为空" })); } if (verifyCode != (string)TempData["AdminVerifyCode"]) { return(Json(new AjaxResult { Status = "0", Msg = "验证码错误" })); } long result = AdminService.CheckLogin(username, password); if (result <= 0) { return(Json(new AjaxResult { Status = "0", Msg = "账户名或密码不正确" })); } long id = AdminService.GetIdByName(username); MVCHelper.LoginCookie(username, "A128076_admin", false); HttpCookie UserCookie = new HttpCookie("A128076_admin"); UserCookie["ID"] = id.ToString(); UserCookie["Name"] = username; Response.AppendCookie(UserCookie); return(Json(new AjaxResult { Status = "1", Data = "/admin/home/index" })); }
public ActionResult Login(string usercode, string password, string verifyCode) { if (string.IsNullOrEmpty(usercode)) { return(Json(new AjaxResult { Status = "0", Msg = "账户名不能为空" })); } if (string.IsNullOrEmpty(password)) { return(Json(new AjaxResult { Status = "0", Msg = "密码不能为空" })); } if (string.IsNullOrEmpty(verifyCode)) { return(Json(new AjaxResult { Status = "0", Msg = "验证码不能为空" })); } if (verifyCode != (string)TempData["verifyCode"]) { return(Json(new AjaxResult { Status = "0", Msg = "验证码错误" })); } long result = userService.CheckLogin(usercode, CommonHelper.GetMD5(password.Trim())); if (result <= 0) { return(Json(new AjaxResult { Status = "0", Msg = "账户名或密码不正确" })); } MVCHelper.LoginCookie(usercode, "A128076_user", false); HttpCookie UserCookie = new HttpCookie("A128076_user"); UserCookie["ID"] = result.ToString(); UserCookie["Name"] = usercode; Response.AppendCookie(UserCookie); return(Json(new AjaxResult { Status = "1", Data = "/home/index" })); }