/// <summary> /// 找回密码 /// </summary> /// <param name="phone">手机号码</param> /// <param name="newPwd">新密码</param> /// <param name="rePwd">原来的密码</param> /// <returns></returns> /// <remarks>added by jimmy,2015-9-29</remarks> public JsonResult CommitNewPwd(string phone, string newPwd, string rePwd) { SuppliersModel model = _suppliersService.GetSuppliersByPhone(phone).Data; if (model == null) { //return Json(new { rs = 0, msg = CultureHelper.GetLangString("LOGIN_GETPASSWORD_USERNOTEXIST") }); return(Json(new { rs = 0, msg = "用户不存在" })); } if (newPwd == null || newPwd == "") { // return Json(new { rs = 0, msg = CultureHelper.GetLangString("LOGIN_NEWPWD_PWDMESSAGE") }); return(Json(new { rs = 0, msg = "密码不能为空,请重新输入" })); } if (newPwd.Length < 8 || new Regex(@"^[A-Za-z]+$").IsMatch(newPwd) || new Regex(@"^[0-9]*$").IsMatch(newPwd)) { //return Json(new { rs = 0, msg = CultureHelper.GetLangString("LOGIN_GETPASSWORD_PASSWORD") }); return(Json(new { rs = 0, msg = "密码由8-16位数字、字母或特殊字符组成,区分大小写" })); } if (newPwd.Length > 16 && new Regex(@"[^\x00-\xff]|\s").IsMatch(newPwd)) { //return Json(new { rs = 0, msg = CultureHelper.GetLangString("LOGIN_GETPASSWORD_PASSWORD") }); return(Json(new { rs = 0, msg = "密码由8-16位数字、字母或特殊字符组成,区分大小写" })); } if (string.IsNullOrEmpty(rePwd)) { // return Json(new { rs = 0, msg = CultureHelper.GetLangString("LOGIN_PWD_NOTNULL") }); return(Json(new { rs = 0, msg = "请输入确认密码!" })); } if (newPwd != rePwd) { // return Json(new { rs = 0, msg = CultureHelper.GetLangString("LOGIN_PWD_CONFIRM_TWO") }); return(Json(new { rs = 0, msg = "两次输入的密码不一致!" })); } else { model.PassWord = CodeHelper.GetMD5(newPwd); model.UpdateDT = DateTime.Now; if (_suppliersService.UpdatePwd(model).Data == 1) { //return Json(new { rs = 1, msg = CultureHelper.GetLangString("LOGIN_PWD_UPDATE_SUCCESS") });//修改密码成功! return(Json(new { rs = 1, msg = "修改密码成功!" }));//修改密码成功! } else { //return Json(new { rs = 0, msg = CultureHelper.GetLangString("LOGIN_UPDATE_PWD_FAILURE") });//修改密码失败! return(Json(new { rs = 0, msg = "修改密码失败!" }));//修改密码失败! } } }
public JsonResult UpdatePass(string PassWord, string NewPassWord, string okPassWord) { if (string.IsNullOrEmpty(NewPassWord)) { return(Json(new { rs = 0, msg = "LOGIN_GETPASSWORD_PWDNOTEMPTY" }));//密码不能为空 } if (!NewPassWord.Equals(okPassWord)) { return(Json(new { rs = 0, msg = "USERINFO_TWO_PASSWORD_NOT_SAME" }));//新密码与确认密码不一致! } SuppliersModel model = _suppliersService.GetSuppliersByPhone("098888888").Data; if (model == null) { return(Json(new { rs = 0, msg = "USERINFO_USER_NOT_EXIST" }));//用户不存在! } if (!model.PassWord.Equals(FormsAuthentication.HashPasswordForStoringInConfigFile(PassWord, "MD5"))) { return(Json(new { rs = 0, msg = "USERINFO_ORIGINAL_PASSWORD_INCORRECT" }));//原始密码不正确! } if (model.PassWord.Equals(FormsAuthentication.HashPasswordForStoringInConfigFile(NewPassWord, "MD5"))) { return(Json(new { rs = 0, msg = "LOGIN_GETPASSWORD_NOTCONSISTENTPWD" }));//新密码不能与旧密码一致! } model.PassWord = FormsAuthentication.HashPasswordForStoringInConfigFile(NewPassWord, "MD5"); model.UpdateDT = DateTime.Now; if (_suppliersService.UpdatePwd(model).Data == 1) { FormsAuthentication.SignOut(); return(Json(new { rs = 1, msg = "USERINFO_UPDATE_SUCCESS" }));//修改成功! } return(Json(new { rs = 0, msg = "USERINFO_UPDATE_FAILURE" }));//修改失败! }