public ActionResult AjaxCheckRegisterEmail(string CustomerEmail) { if (LoginFacade.IsCustomerEmailExist(CustomerEmail)) { return(Json("该邮箱已经被注册", JsonRequestBehavior.AllowGet)); } return(Json("s", JsonRequestBehavior.AllowGet)); }
public ActionResult AjaxRegister() { var model = new RegisterVM(); this.TryUpdateModel <RegisterVM>(model); //if (CookieHelper.GetCookie<String>("VerifyCode").ToLower() == model.ValidatedCode.ToLower()) //{ if (model.Password != model.RePassword) { return(Json("密码与确认密码不相同", JsonRequestBehavior.AllowGet)); } model.Password = HttpUtility.UrlDecode(model.Password.Replace("+", "%2b")); CustomerInfo item = EntityConverter <RegisterVM, CustomerInfo> .Convert(model); item.InitRank = 1; item.CustomerName = item.CustomerID; //if (!CheckPasswordPolicy(item.Password)) // return Json("密码格式不正确,密码必须是字母与数据的组合", JsonRequestBehavior.AllowGet); if (LoginFacade.IsExistCustomer(item.CustomerID)) { return(Json(new JsonResult() { ContentType = "f", Data = "该账户名已经被注册" }, JsonRequestBehavior.AllowGet)); } if (LoginFacade.IsCustomerEmailExist(item.Email)) { return(Json(new JsonResult() { ContentType = "f", Data = "该邮箱已经被注册" }, JsonRequestBehavior.AllowGet)); } //密码处理 string encryptPassword = string.Empty; string password = item.Password; string passwordSalt = string.Empty; PasswordHelper.GetNewPasswordAndSalt(ref password, ref encryptPassword, ref passwordSalt); item.Password = encryptPassword; item.PasswordSalt = passwordSalt; if (LoginFacade.CreateCustomer(item).SysNo > 0) { LoginUser lUser = new LoginUser(); lUser.UserDisplayName = item.CustomerName; lUser.UserID = item.CustomerID; lUser.UserSysNo = item.SysNo; lUser.RememberLogin = false; lUser.LoginDateText = DateTime.Now.ToString(); lUser.TimeoutText = DateTime.Now.AddMinutes(int.Parse(ConfigurationManager.AppSettings["LoginTimeout"].ToString())).ToString(); CookieHelper.SaveCookie <LoginUser>("LoginCookie", lUser); //更新数据 bool result = CustomerFacade.UpdateCellPhoneCustomerSysNoByID(int.Parse(model.CellPhoneCode), lUser.UserSysNo); return(Json(new JsonResult() { ContentType = "s", Data = lUser.UserSysNo }, JsonRequestBehavior.AllowGet)); } return(Json(new JsonResult() { ContentType = "f", Data = "用户注册失败,请稍后重试" }, JsonRequestBehavior.AllowGet)); //} //return Json(new JsonResult() { ContentType = "y", Data = "验证码不正确" }, JsonRequestBehavior.AllowGet); }