public async Task <JsonResult> StartRegisterBySendingVerificationRequest(PhoneVerificationRequestModel verificationRequest) { var response = new ResultModel(); if (!ModelState.IsValid) { return(JsonModelStateErrors()); } var validPhone = await _authy.ValidatePhoneAsync(verificationRequest.CountryCode, verificationRequest.PhoneNumber); if (!validPhone.IsSuccess) { return(Json(validPhone.ToBase())); } var isUsedPhoneCheck = await _authy.CheckIfPhoneIsUsedByAnotherUserAsync(validPhone.Result); if (!isUsedPhoneCheck.IsSuccess) { return(Json(isUsedPhoneCheck)); } var userName = _authy.NormalizePhoneNumber(verificationRequest.CountryCode, verificationRequest.PhoneNumber); var user = await _userManager.UserManager.FindByNameAsync(userName); if (user != null) { response.Errors.Add(new ErrorModel(string.Empty, "The user already exists")); return(Json(response)); } HttpContext.Session.Set("phone_verification_request", verificationRequest); var result = await _authy.PhoneVerificationRequestAsync( verificationRequest.CountryCode, verificationRequest.PhoneNumber, verificationRequest.Via ); return(Json(result)); }