public async Task <ActionResult> ResetPassword(ResetPasswordInfo model) { model.ReconstructSettings(); this.ViewData[ResetPasswordInfo.Key] = model; LoadPage(model.Settings.Uri); var settings = model.Settings; if (settings.UseValidateHuman) { bool IsValidated = model.ValidateHuman.ValidateValue(model.ValidationValue); if (!IsValidated) { ModelState.AddModelError("ValidationValue", model.ValidateHuman.AltValidationFailText); model.ValidationValue = String.Empty; } } if (String.IsNullOrEmpty(settings.UserCode)) { ModelState.AddModelError(String.Empty, "Reset code not provided."); } if (ModelState.IsValid) { string confirmView = settings.PostPartialName; if (!String.IsNullOrEmpty(settings.PostPartialName)) { confirmView = settings.PostPartialConfirmation; } var user = await securityHelper.UserManager.FindByEmailAsync(model.Email); if (user == null) { return(PartialView(confirmView, model)); } else { SecurityData sd = new SecurityData(); var result = sd.ResetPassword(user, settings.UserCode, model.Password); model.CreationResult = result; if (result.Succeeded) { return(PartialView(confirmView, model)); } AddErrors(result); } } Helper.HandleErrorDict(ModelState); return(PartialView(settings.PostPartialName, model)); }
public async Task <ActionResult> ForgotPassword(ForgotPasswordInfo model) { model.ReconstructSettings(); this.ViewData[ForgotPasswordInfo.Key] = model; LoadPage(model.Settings.Uri); var settings = model.Settings; if (settings.UseValidateHuman) { bool IsValidated = model.ValidateHuman.ValidateValue(model.ValidationValue); if (!IsValidated) { ModelState.AddModelError("ValidationValue", model.ValidateHuman.AltValidationFailText); model.ValidationValue = String.Empty; } } string confirmView = settings.PostPartialName; if (!String.IsNullOrEmpty(settings.PostPartialName)) { confirmView = settings.PostPartialConfirmation; } string confirmUri = settings.Uri; if (!String.IsNullOrEmpty(settings.ConfirmUri)) { confirmUri = settings.ConfirmUri; } if (ModelState.IsValid) { var user = await securityHelper.UserManager.FindByEmailAsync(model.Email); if (user != null) { SecurityData sd = new SecurityData(); sd.ResetPassword(confirmUri, model.Email); } return(PartialView(confirmView, model)); } Helper.HandleErrorDict(ModelState); return(PartialView(settings.PostPartialName, model)); }