public async Task <bool> Handle(ResetPasswordCommand request, CancellationToken cancellationToken) { var user = await _userManager.FindByEmailAsync(request.Email); if (user == null) { throw new RestException(HttpStatusCode.Unauthorized); } var passwordReset = await _userManager.ResetPasswordAsync(user, request.ResetPasswordToken, request.NewPassword); if (!passwordReset.Succeeded) { const string exceptionMessage = "Problem resetting password"; _failedIdentityResult.Handle(user, passwordReset.Errors, exceptionMessage); } var passwordChangedHtml = _emailBuilder.PasswordChangedEmail(user.FirstName); var emailToSend = new Email { FirstName = user.FirstName, HtmlContent = passwordChangedHtml, PlainTextContent = null, Subject = EmailSubjects.PasswordHasBeenChanged, To = user.Email, UserId = user.Id }; _eventBus.Publish(new PasswordChangedEvent(user.Id)); _eventBus.Publish(new SendEmailEvent(emailToSend)); return(await Task.FromResult(true)); }