public async Task <IActionResult> ForgetPassword([FromBody] ForgetPasswordCommand command) { try { if (command == null || string.IsNullOrEmpty(command.Email)) { return(await Response(null, new List <Notification> { new Notification("Email", "Emmail inválido") })); } var result = _authenticateAppService.RecuperarSenha(command.Email); if (result) { return(await Response(result, null)); } else { return(await Response(null, new List <Notification> { new Notification("Email", "Ocorreu um erro ao recuperar a senha") })); } } catch (Exception ex) { return(await Response(null, new List <Notification> { new Notification("ResetSenha", ex.Message) })); } }
public async Task <Result <bool> > Handle(ForgetPasswordCommand request, CancellationToken cancellationToken) { try { var user = await _userRepository.GetUserByEmail(request.Email); if (user == null) { return(Result <bool> .BadRequest($"User with {request.Email} email doesn't exist!")); } if (!user.IsConfirmed) { return(Result <bool> .BadRequest($"User is not activated!")); } var token = TokenHelper.GenerateToken(user.PasswordSalt); SendResetEmail(user.Email, $"{user.FirstName} {user.LastName}", token); return(Result <bool> .Ok(true)); } catch (Exception e) { return(Result <bool> .Failure(e.Message)); } }
public async Task <IActionResult> ForgetPassword([FromBody] ForgetPasswordCommand forgetPasswordCommand) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _mediator.Send(forgetPasswordCommand); return(StatusCodeResult(result)); }
public async Task <ICommandResult> ForgetPassword([FromBody] ForgetPasswordCommand command) { var result = _handler.Handle(command); return(result); }
public ICommandResult Handle(ForgetPasswordCommand command) { throw new NotImplementedException(); }
public async Task <IActionResult> ForgetPassword(ForgetPasswordCommand request) { return(Ok(await _mediator.Send(request))); }