public ActionResult MemberResetPasswordRenderForm() { var model = new MemberResetPasswordModel(); model.ValidateGUID = "dummy"; // dummy return(PartialView("Account/MemberResetPassword", model)); }
public ActionResult MemberResetPassword(MemberResetPasswordModel model) { if (!ModelState.IsValid) { return(this.Fail(ModelState.Values.First(e => e.Errors.Count > 0).Errors[0].ErrorMessage)); } MiddleTier.MemberManager.SysMemberResetPassword(model.UserName, model.Password); return(this.Success()); }
public ActionResult MemberResetPasswordPost(MemberResetPasswordModel model) { if (ModelState.IsValid) { var memberService = Services.MemberService; var member = memberService.GetByEmail(model.Email); if (member != null) { string validateGuid = System.Guid.NewGuid().ToString("N"); // set the expiry to be 24 hours. member.SetValue("validateGUID", validateGuid); member.SetValue("validateGUIDExpiry", DateTime.Now.AddHours(2)); // remember to save memberService.Save(member); // Set up the info for the valdiation email Dictionary <string, string> emailFields = new Dictionary <string, string> { { "FIRSTNAME", member.GetValue <string>("firstName") }, { "LASTNAME", member.GetValue <string>("lastName") }, { "EMAIL", model.Email }, { "VALIDATEGUID", validateGuid }, { "DOMAIN", HttpContext.Request.Url.Authority } }; // Send the password reset email bool emailSent = EmailHelper.SendEmail("Password Reset Email", "*****@*****.**", model.Email, emailFields); TempData["Status"] = "A password reset email has been sent to the email address."; return(CurrentUmbracoPage()); } else { // Security decision here - you can either inform the user the email address supplied is not valid or pretend it is (to mask wether there is an account). TempData["Status"] = "A password reset email has been sent to the email address."; return(CurrentUmbracoPage()); } } else { // model is invalid TempData["Status"] = "Invalid email address supplied."; return(CurrentUmbracoPage()); } }