public void NothingShouldHappenIfEmailIsNotFound() { ResetPasswordStepOneRequest request = new ResetPasswordStepOneRequest { Email = "asdf" }; _resetPasswordStepOneHandler.Handle(request); BodyFitTrackerContext bodyFitTrackerContext = DatabaseConnectionFactory.GetInMemoryDatabase(false); Assert.AreEqual(0, bodyFitTrackerContext.PasswordResets.Count()); }
public void IfEmailIsFoundAPasswordResetShouldBeCreated() { ResetPasswordStepOneRequest request = new ResetPasswordStepOneRequest { Email = _userEmail }; _resetPasswordStepOneHandler.Handle(request); BodyFitTrackerContext bodyFitTrackerContext = DatabaseConnectionFactory.GetInMemoryDatabase(false); Assert.AreEqual(1, bodyFitTrackerContext.PasswordResets.Count()); }
public void Handle(ResetPasswordStepOneRequest resetPasswordStepOneRequest) { AppUser appUser = _bodyFitTrackerContext.AppUsers.Where(x => x.Email == resetPasswordStepOneRequest.Email).FirstOrDefault(); if (appUser == null) { return; } string resetToken = _passwordResetTokenGenerator.CreateResetToken(); DateTime expiration = DateTime.Now.AddHours(1); PasswordReset passwordReset = new PasswordReset(resetToken, appUser.AppUserId, expiration); EmailMessage emailMessage = CreateEmailMessage(appUser, resetToken); _emailSender.SendEmail(emailMessage); _bodyFitTrackerContext.PasswordResets.Add(passwordReset); _bodyFitTrackerContext.SaveChanges(); }
public void ResetPasswordStepOne(ResetPasswordStepOneRequest resetPasswordStepOneRequest) { _resetPasswordStepOneHandler.Handle(resetPasswordStepOneRequest); }