public void Should_not_have_error_when_newPassword_equals_confirmationPassword() { var model = new ForgotPasswordConfirmViewModel { NewPassword = "******", ConfirmNewPassword = "******" }; _validator.ShouldNotHaveValidationErrorFor(x => x.NewPassword, model); }
public void Should_not_have_error_when_confirmNewPassword_is_specified() { var model = new ForgotPasswordConfirmViewModel { ConfirmNewPassword = "******" }; //wnew password should equal confirmation password model.NewPassword = model.ConfirmNewPassword; _validator.ShouldNotHaveValidationErrorFor(x => x.ConfirmNewPassword, model); }
public void Should_have_error_when_confirmNewPassword_is_null_or_empty() { var model = new ForgotPasswordConfirmViewModel { ConfirmNewPassword = null }; _validator.ShouldHaveValidationErrorFor(x => x.ConfirmNewPassword, model); model.ConfirmNewPassword = ""; _validator.ShouldHaveValidationErrorFor(x => x.ConfirmNewPassword, model); }
public void Should_have_error_when_newPassword_is_null_or_empty() { var model = new ForgotPasswordConfirmViewModel { NewPassword = null }; //new password should equal confirmation password model.ConfirmNewPassword = model.NewPassword; _validator.ShouldHaveValidationErrorFor(x => x.NewPassword, model); model.NewPassword = ""; //new password should equal confirmation password model.ConfirmNewPassword = model.NewPassword; _validator.ShouldHaveValidationErrorFor(x => x.NewPassword, model); }
public void Should_validate_on_PasswordRecoveryConfirmModel_is_all_rule() { _forgotPasswordConfirmValidator = new ForgotPasswordConfirmValidator(_userSettings); var model = new ForgotPasswordConfirmViewModel() { NewPassword = "******" }; //new password should equal confirmation password model.ConfirmNewPassword = model.NewPassword; _forgotPasswordConfirmValidator.ShouldHaveValidationErrorFor(x => x.NewPassword, model); model.NewPassword = "******"; //new password should equal confirmation password model.ConfirmNewPassword = model.NewPassword; _forgotPasswordConfirmValidator.ShouldNotHaveValidationErrorFor(x => x.NewPassword, model); }
public async Task <IActionResult> ForgotPasswordConfirmPost(string token, string email, ForgotPasswordConfirmViewModel model) { var user = await _userService.GetUserByEmailAsync(email); if (user == null) { return(RedirectToRoute("Login")); } //validate token if (!await _userService.IsPasswordRecoveryTokenValidAsync(user, token)) { model.DisablePasswordChanging = true; model.Result = "Wrong password recovery token"; return(View(model)); } if (await _userService.IsPasswordRecoveryLinkExpired(user)) { model.DisablePasswordChanging = true; model.Result = "Your password recovery link is expired"; return(View(model)); } if (ModelState.IsValid) { var response = await _userRegistrationService.ChangePasswordAsync(new ChangePasswordRequest(email, false, _userSettings.DefaultPasswordFormat, model.NewPassword)); if (response.Success) { await _genericAttributeService.SaveAttributeAsync(user, UserDefaults.PasswordRecoveryTokenAttribute, ""); model.DisablePasswordChanging = true; model.Result = "Your password has been changed"; } else { model.Result = response.Errors.FirstOrDefault(); } return(View(model)); } //If we got this far, something failed, redisplay form return(View(model)); }
public Task <ForgotPasswordConfirmViewModel> PrepareForgotPasswordConfirmModel() { var model = new ForgotPasswordConfirmViewModel(); return(Task.FromResult(model)); }