public async Task <AcountResponse> ResetLoggedPassword(AcountResetPasswordLoggedRequest acountResetPasswordLoggedRequest) { var user = await _identityService.FindByEmailAsync(acountResetPasswordLoggedRequest.Email); if (user is null) { return new AcountResponse { Message = "One or more validation errors occurred.", Erros = new string[1] { "User not found!" } } } ; var validToken = await _identityService.GeneratePasswordResetTokenAsync(user); var result = await _identityService.ResetPasswordAsync(user, validToken, acountResetPasswordLoggedRequest.Password); if (result.Succeeded) { _acountHistoryRepository.Add(_entityHistoryFactory.GetEntityHistory(user, Domain.Domain.DomainHistory.Enums.RequestActionEnum.Update) as AcountHistory); return(new AcountResponse { Message = "Password has been reset successfuly" }); } return(new AcountResponse { Message = "One or more validation errors occurred.", Erros = result.Errors.Select(e => e.Description) }); } }
public async Task <ActionResult> ResetLoggedPassword(AcountResetPasswordLoggedRequest acountResetPasswordLoggedRequest) { if (ModelState.IsValid) { var result = await _acountServices.ResetLoggedPassword(acountResetPasswordLoggedRequest); if (result.IsSuccess) { return(Ok(result)); } return(BadRequest(result)); } return(BadRequest("Some properties are not valid")); }