public void CanPasswordUpdateOrNot() { string passwrodHash = _dockyardAccountDO.PasswordHash; using (var uow = ObjectFactory.GetInstance <IUnitOfWork>()) { _fr8Account.UpdatePassword(uow, null, "abc"); Assert.AreEqual(passwrodHash, _dockyardAccountDO.PasswordHash); _fr8Account.UpdatePassword(uow, _dockyardAccountDO, "abc"); Assert.AreNotEqual(passwrodHash, _dockyardAccountDO.PasswordHash); } }
public IHttpActionResult Update(string oldPassword, string newPassword) { if (string.IsNullOrEmpty(oldPassword)) { throw new Exception("Old password is required."); } using (var uow = ObjectFactory.GetInstance <IUnitOfWork>()) { var user = uow.UserRepository.FindOne(u => u.EmailAddress.Address == User.Identity.Name); if (_fr8Account.IsValidHashedPassword(user, oldPassword)) { _fr8Account.UpdatePassword(uow, user, newPassword); uow.SaveChanges(); } else { throw new Exception("Invalid current password."); } } return(Ok()); }