public ActionResult ResetPassword(long userId, string verifyCode, string userName, string pwd) { if (userId == 0 || string.IsNullOrEmpty(verifyCode) || string.IsNullOrEmpty(pwd)) { return(Json(new AjaxResult { Status = "Error", ErrorMsg = "信息不完整" })); } //查询验证码是否有效 var verify = VerifyService.GetVerify(userId); if (verify == null) { return(Json(new AjaxResult { Status = "Error", ErrorMsg = "验证码无效" })); } //判断用户名是否输入正确 var user = UserService.GetUserById(userId); if (user.UserName != userName) { return(Json(new AjaxResult { Status = "Error", ErrorMsg = "用户名错误" })); } //重置密码 if (UserService.ResetPassword(userId, pwd)) { //修改验证码状态 VerifyService.UpdateValid(userId); LogService.Add(userId, 7, "重置密码成功"); return(Json(new AjaxResult { Status = "OK" })); } return(Json(new AjaxResult { Status = "Error", ErrorMsg = "修改密码失败,请稍后重试" })); }