public HtmlHelper <ResetPasswordInfo> GetModelHelper(string partialName, IValidateHuman validateHuman = null) { _model = InitResetPasswordInfo(partialName); _settings.SetHuman(validateHuman); return(InitHelp()); }
public HtmlHelper <ResetPasswordInfo> GetModelHelper(ResetPasswordInfoConfig config) { _model = InitResetPasswordInfo(config.PostPartialName); _settings.GetSettingFromConfig(config); _settings.PostPartialConfirmation = config.PostPartialConfirmation; return(InitHelp()); }
protected ResetPasswordInfo InitResetPasswordInfo(string partialName) { ResetPasswordInfo model = new ResetPasswordInfo(); _settings = new ResetPasswordInfoSettings(); if (_helper.ViewData[ResetPasswordInfo.Key] != null) { model = _helper.ViewData[ResetPasswordInfo.Key] as ResetPasswordInfo; } else { model = new ResetPasswordInfo(); } _settings.Uri = CarrotCakeHtml.CmsPage.ThePage.FileName; _settings.PostPartialName = partialName; _settings.UserCode = ResetPasswordInfoSettings.CodeUrl; model.Settings = _settings; return(model); }
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 HtmlHelper <ResetPasswordInfo> GetModelHelper(string partialName) { _model = InitResetPasswordInfo(partialName); return(InitHelp()); }