public void UsersPasswordShouldBeSuccessfullyUpdatedAssumingTokenIsFoundAndNotExipred() // see token validation tests to see what happens if token is invalid { ResetPasswordStepTwoRequest request = new ResetPasswordStepTwoRequest { NewPassword = "******", ConfirmedNewPassword = "******", ResetPasswordToken = _passwordResetToken }; ResetPasswordStepTwoResult result = _resetPasswordStepTwoHandler.Handle(request); BodyFitTrackerContext bodyFitTrackerContext = DatabaseConnectionFactory.GetInMemoryDatabase(false); AppUser appUser = bodyFitTrackerContext.AppUsers.Where(x => x.Email == _appUserEmail).First(); Assert.IsTrue(result.Succeeded); Assert.AreEqual(request.NewPassword, appUser.HashedPassword); }
public ResetPasswordStepTwoResult Handle(ResetPasswordStepTwoRequest resetPasswordStepTwoRequest) { ValidateResetPasswordTokenHandler validateResetPasswordTokenHandler = new ValidateResetPasswordTokenHandler(_bodyFitTrackerContext); ResetPasswordValidationResult validationResult = validateResetPasswordTokenHandler.Handle(resetPasswordStepTwoRequest.ResetPasswordToken); if (!validationResult.Succeeded) { return(new ResetPasswordStepTwoResult(false, validationResult.ErrorMessage)); } PasswordReset passwordReset = _bodyFitTrackerContext.PasswordResets .Where(x => x.Token == resetPasswordStepTwoRequest.ResetPasswordToken).First(); AppUser appUser = passwordReset.AppUser; (string hashedPassword, string salt) = _passwordHasher.GeneratePassword(resetPasswordStepTwoRequest.NewPassword); appUser.HashedPassword = hashedPassword; appUser.Salt = salt; _bodyFitTrackerContext.PasswordResets.Remove(passwordReset); _bodyFitTrackerContext.SaveChanges(); return(new ResetPasswordStepTwoResult(true)); }
public ResetPasswordStepTwoResult ResetPasswordStepTwo(ResetPasswordStepTwoRequest resetPasswordStepTwoRequest) { return(_resetPasswordStepTwoHandler.Handle(resetPasswordStepTwoRequest)); }