[HttpPost("register")] //<host>/api/auth/register public async Task <IActionResult> Register([FromBody] UserForRegisterDto userForRegisterDto) { // Data Transfer Object containing username and password. // validate request if (!ModelState.IsValid) { return(BadRequest(ModelState)); } userForRegisterDto.Email = userForRegisterDto.Email.ToLower(); //Convert username to lower case before storing in database. if (await _repo.UserExists(userForRegisterDto.Email, userForRegisterDto.NumeroCliente)) { return(BadRequest(false)); } var userToCreate = new Users { Email = userForRegisterDto.Email, NumeroCliente = userForRegisterDto.NumeroCliente }; var createUser = await _repo.Register(userToCreate, userForRegisterDto.Password); EnviarCorreos correos = new EnviarCorreos(); var codigoMensajeSeEnvio = correos.CrearCorreo(createUser.Email, createUser.NumeroVerificacion); return(Ok(new { createUser.Id })); }
public IActionResult ReenviarCorreo(string email) { EnviarCorreos correos = new EnviarCorreos(); var numConfirmaionNuevo = _repo.NumeroConfirmacion(); _repo.ActualizarNumeroConfirmacion(email, numConfirmaionNuevo); if (correos.CrearCorreo(email, numConfirmaionNuevo)) { return(Ok(true)); } else { return(Ok(false)); } }