public async Task <IActionResult> RequestVerification([FromForm] VerificationChallengeDto dto) { if (!ModelState.IsValid) { return(BadRequest()); } if (_configuration.CountriesBlackList.Contains(dto.ParseCountryCode())) { return(BadRequest($"Country [{dto.CountryCode}] is not supported.")); } var number = dto.ToString(); _logger.LogInformation($"The PhoneNumber [{number}] is requesting an verification code."); //Create request object var request = new VerificationToken(number, _configuration.VerificationDuration, CodeGenerator.GetCode()); //Send SMS message with code to client var clientMessage = $"Hello from YoApp!\nYour verification Code is:\n{request.Code}"; var sendingResult = await _messageSender.SendMessageAsync("+" + number, clientMessage); if (!sendingResult) { return(new StatusCodeResult(500)); } //Persist the request to resolve it later await _dataWorker.VerificationTokens.AddOrReplaceAsync(request); await _dataWorker.CompleteAsync(); return(Ok()); }