public RedirectToRouteResult ResetPassword(Guid id) { var user = _userService.Get(id); var pass = FDIUtils.RandomString(6).ToLower(); _passwordService.ChangePassword(user, pass); return(RedirectToAction("Password", new { id })); }
public ActionResult ResetPassword(int id) { var msg = new JsonMessage(); var customer = _da.GetById(id); var pass = FDIUtils.RandomString(4).ToLower(); const string stringRegexCheckEmailOrWith = @"^(([^<>()[\]\\.,;:\s@\""]+" + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@" + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+" + @"[a-zA-Z]{2,}))$"; if (!string.IsNullOrEmpty(customer.Email) && Regex.IsMatch(customer.Email, stringRegexCheckEmailOrWith)) { _da.Save(); msg = new JsonMessage { Erros = false, ID = customer.ID.ToString(), Message = string.Format("Đã Reset lại password: <b>{0}</b>", Server.HtmlEncode(customer.FullName)) }; return(Json(msg, JsonRequestBehavior.AllowGet)); } if (!string.IsNullOrEmpty(customer.Phone)) { _da.Save(); msg = new JsonMessage { Erros = false, ID = customer.ID.ToString(), Message = string.Format("Đã Reset lại password: <b>{0}</b>", Server.HtmlEncode(customer.FullName)) }; //FDIUtils.SendSMSToCustomer(customer.UserName, customer.Mobile, customer.Mobile, pass); } if (string.IsNullOrEmpty(msg.Message)) { msg.Message = "Email khách hàng không đúng và Sđt không có!"; msg.Erros = true; } return(Json(msg, JsonRequestBehavior.AllowGet)); }