public async Task <IActionResult> ResendConfirmEmail([FromBody] ResendConfirmEmailCommand registerCommand)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _mediator.Send(registerCommand);

            return(StatusCodeResult(result));
        }
Exemple #2
0
        public async Task <Result <bool> > Handle(ResendConfirmEmailCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var user = await _userRepository.GetUserByEmail(request.Email);

                if (user == null)
                {
                    return(Result <bool> .BadRequest($"User doesn't exist"));
                }

                var confirmationToken = TokenHelper.GenerateToken(user.PasswordSalt);

                SendConfirmationEmail(request.Email, $"{user.FirstName} {user.LastName}", confirmationToken);

                return(Result <bool> .Ok(true));
            }
            catch (Exception e)
            {
                return(Result <bool> .Failure(e.Message));
            }
        }