Add td_api::phoneNumberAuthenticationSettings and support automatic code retrival from SMS on Android.

GitOrigin-RevId: f97bd5bf3eb7449da1b14242fa47537801657b04
This commit is contained in:
levlam 2019-05-03 05:44:59 +03:00
parent eed517a2e7
commit 68b2d10fdb
15 changed files with 88 additions and 79 deletions

View File

@ -263,8 +263,7 @@ class TdExample {
std::cerr << "Enter phone number: ";
std::string phone_number;
std::cin >> phone_number;
send_query(td_api::make_object<td_api::setAuthenticationPhoneNumber>(
phone_number, false /*allow_flash_calls*/, false /*is_current_phone_number*/),
send_query(td_api::make_object<td_api::setAuthenticationPhoneNumber>(phone_number, nullptr),
create_authentication_query_handler());
},
[this](td_api::authorizationStateWaitEncryptionKey &) {

View File

@ -93,7 +93,7 @@ namespace TdExample
else if (_authorizationState is TdApi.AuthorizationStateWaitPhoneNumber)
{
string phoneNumber = ReadLine("Please enter phone number: ");
_client.Send(new TdApi.SetAuthenticationPhoneNumber(phoneNumber, false, false), new AuthorizationRequestHandler());
_client.Send(new TdApi.SetAuthenticationPhoneNumber(phoneNumber, null), new AuthorizationRequestHandler());
}
else if (_authorizationState is TdApi.AuthorizationStateWaitCode)
{

View File

@ -108,7 +108,7 @@ public final class Example {
break;
case TdApi.AuthorizationStateWaitPhoneNumber.CONSTRUCTOR: {
String phoneNumber = promptString("Please enter phone number: ");
client.send(new TdApi.SetAuthenticationPhoneNumber(phoneNumber, false, false), new AuthorizationRequestHandler());
client.send(new TdApi.SetAuthenticationPhoneNumber(phoneNumber, null), new AuthorizationRequestHandler());
break;
}
case TdApi.AuthorizationStateWaitCode.CONSTRUCTOR: {

View File

@ -94,7 +94,7 @@ namespace TdApp
{
var args = command.Split(" ".ToCharArray(), 2);
AcceptCommand(command);
_client.Send(new TdApi.SetAuthenticationPhoneNumber(args[1], false, false), _handler);
_client.Send(new TdApi.SetAuthenticationPhoneNumber(args[1], null), _handler);
}
else if (command.StartsWith("cac"))
{

View File

@ -1619,6 +1619,14 @@ callStateError error:error = CallState;
call id:int32 user_id:int32 is_outgoing:Bool state:CallState = Call;
//@description Contains settings for the authentication of the user's phone number
//@allow_flash_call Pass true if the authentication code may be sent via flash call to the specified phone number
//@is_current_phone_number Pass true if the authenticated phone number is used on the current device
//@app_specific_sms_token If you want to automatically receive the authentication code from SMS in Android >= 26, pass a single use app specific 11-character token received from SmsManager.createAppSpecificSmsToken. If specified, this token is preferred over app_hash_string
//@app_hash_string If you want to use Android SMS Retriever API (requires Google Play Services >= 11.0), pass an 11-character hash string that identifies your app. See https://developers.google.com/identity/sms-retriever/ for more details
phoneNumberAuthenticationSettings allow_flash_call:Bool is_current_phone_number:Bool app_specific_sms_token:string app_hash_string:string = PhoneNumberAuthenticationSettings;
//@description Represents a list of animations @animations List of animations
animations animations:vector<animation> = Animations;
@ -2720,9 +2728,10 @@ setTdlibParameters parameters:tdlibParameters = Ok;
//@description Checks the database encryption key for correctness. Works only when the current authorization state is authorizationStateWaitEncryptionKey @encryption_key Encryption key to check or set up
checkDatabaseEncryptionKey encryption_key:bytes = Ok;
//@description Sets the phone number of the user and sends an authentication code to the user. Works only when the current authorization state is authorizationStateWaitPhoneNumber
//@phone_number The phone number of the user, in international format @allow_flash_call Pass true if the authentication code may be sent via flash call to the specified phone number @is_current_phone_number Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false
setAuthenticationPhoneNumber phone_number:string allow_flash_call:Bool is_current_phone_number:Bool = Ok;
//@description Sets the phone number of the user and sends an authentication code to the user. Works only when the current authorization state is authorizationStateWaitPhoneNumber,
//-or if there is no pending authentication query and the current authorization state is authorizationStateWaitCode or authorizationStateWaitPassword
//@phone_number The phone number of the user, in international format @settings Settings for the authentication of the user's phone number
setAuthenticationPhoneNumber phone_number:string settings:phoneNumberAuthenticationSettings = Ok;
//@description Re-sends an authentication code to the user. Works only when the current authorization state is authorizationStateWaitCode and the next_code_type of the result is not null
resendAuthenticationCode = Ok;
@ -2772,7 +2781,7 @@ setPassword old_password:string new_password:string new_hint:string set_recovery
//@description Returns a 2-step verification recovery email address that was previously set up. This method can be used to verify a password provided by the user @password The password for the current user
getRecoveryEmailAddress password:string = RecoveryEmailAddress;
//@description Changes the 2-step verification recovery email address of the user. If a new recovery email address is specified, then the change will not be applied until the new recovery email address is confirmed
//@description Changes the 2-step verification recovery email address of the user. If a new recovery email address is specified, then the change will not be applied until the new recovery email address is confirmed.
//-If new_recovery_email_address is the same as the email address that is currently set up, this call succeeds immediately and aborts all other requests waiting for an email confirmation @password Password of the current user @new_recovery_email_address New recovery email address
setRecoveryEmailAddress password:string new_recovery_email_address:string = PasswordState;
@ -3480,8 +3489,8 @@ setBio bio:string = Ok;
setUsername username:string = Ok;
//@description Changes the phone number of the user and sends an authentication code to the user's new phone number. On success, returns information about the sent code
//@phone_number The new phone number of the user in international format @allow_flash_call Pass true if the code can be sent via flash call to the specified phone number @is_current_phone_number Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false
changePhoneNumber phone_number:string allow_flash_call:Bool is_current_phone_number:Bool = AuthenticationCodeInfo;
//@phone_number The new phone number of the user in international format @settings Settings for the authentication of the user's phone number
changePhoneNumber phone_number:string settings:phoneNumberAuthenticationSettings = AuthenticationCodeInfo;
//@description Re-sends the authentication code sent to confirm a new phone number for the user. Works only if the previously received authenticationCodeInfo next_code_type was not null
resendChangePhoneNumberCode = AuthenticationCodeInfo;
@ -3712,8 +3721,8 @@ getPreferredCountryLanguage country_code:string = Text;
//@description Sends a code to verify a phone number to be added to a user's Telegram Passport
//@phone_number The phone number of the user, in international format @allow_flash_call Pass true if the authentication code may be sent via flash call to the specified phone number @is_current_phone_number Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false
sendPhoneNumberVerificationCode phone_number:string allow_flash_call:Bool is_current_phone_number:Bool = AuthenticationCodeInfo;
//@phone_number The phone number of the user, in international format @settings Settings for the authentication of the user's phone number
sendPhoneNumberVerificationCode phone_number:string settings:phoneNumberAuthenticationSettings = AuthenticationCodeInfo;
//@description Re-sends the code to verify a phone number to be added to a user's Telegram Passport
resendPhoneNumberVerificationCode = AuthenticationCodeInfo;
@ -3744,8 +3753,8 @@ sendPassportAuthorizationForm autorization_form_id:int32 types:vector<PassportEl
//@description Sends phone number confirmation code. Should be called when user presses "https://t.me/confirmphone?phone=*******&hash=**********" or "tg://confirmphone?phone=*******&hash=**********" link @hash Value of the "hash" parameter from the link
//@phone_number Value of the "phone" parameter from the link @allow_flash_call Pass true if the authentication code may be sent via flash call to the specified phone number @is_current_phone_number Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false
sendPhoneNumberConfirmationCode hash:string phone_number:string allow_flash_call:Bool is_current_phone_number:Bool = AuthenticationCodeInfo;
//@phone_number Value of the "phone" parameter from the link @settings Settings for the authentication of the user's phone number
sendPhoneNumberConfirmationCode hash:string phone_number:string settings:phoneNumberAuthenticationSettings = AuthenticationCodeInfo;
//@description Resends phone number confirmation code
resendPhoneNumberConfirmationCode = AuthenticationCodeInfo;

Binary file not shown.

View File

@ -166,8 +166,8 @@ void AuthManager::check_bot_token(uint64 query_id, string bot_token) {
DcId::main(), NetQuery::Type::Common, NetQuery::AuthFlag::Off));
}
void AuthManager::set_phone_number(uint64 query_id, string phone_number, bool allow_flash_call,
bool is_current_phone_number) {
void AuthManager::set_phone_number(uint64 query_id, string phone_number,
td_api::object_ptr<td_api::phoneNumberAuthenticationSettings> settings) {
if (state_ != State::WaitPhoneNumber) {
if ((state_ == State::WaitCode || state_ == State::WaitPassword) && net_query_id_ == 0) {
// ok
@ -183,13 +183,11 @@ void AuthManager::set_phone_number(uint64 query_id, string phone_number, bool al
return on_query_error(query_id, Status::Error(8, "Phone number can't be empty"));
}
auto r_send_code =
send_code_helper_.send_code(phone_number, allow_flash_call, is_current_phone_number, api_id_, api_hash_);
auto r_send_code = send_code_helper_.send_code(phone_number, settings, api_id_, api_hash_);
if (r_send_code.is_error()) {
send_code_helper_ = SendCodeHelper();
terms_of_service_ = TermsOfService();
r_send_code =
send_code_helper_.send_code(phone_number, allow_flash_call, is_current_phone_number, api_id_, api_hash_);
r_send_code = send_code_helper_.send_code(phone_number, settings, api_id_, api_hash_);
if (r_send_code.is_error()) {
return on_query_error(query_id, r_send_code.move_as_error());
}

View File

@ -32,7 +32,8 @@ class AuthManager : public NetActor {
bool is_authorized() const;
void get_state(uint64 query_id);
void set_phone_number(uint64 query_id, string phone_number, bool allow_flash_call, bool is_current_phone_number);
void set_phone_number(uint64 query_id, string phone_number,
td_api::object_ptr<td_api::phoneNumberAuthenticationSettings> settings);
void resend_authentication_code(uint64 query_id);
void check_code(uint64 query_id, string code, string first_name, string last_name);
void check_bot_token(uint64 query_id, string bot_token);

View File

@ -47,19 +47,16 @@ void PhoneNumberManager::process_send_code_result(uint64 query_id, T r_send_code
start_net_query(NetQueryType::SendCode, G()->net_query_creator().create(create_storer(r_send_code.move_as_ok())));
}
void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number, bool allow_flash_call,
bool is_current_phone_number) {
void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number, Settings settings) {
if (phone_number.empty()) {
return on_query_error(query_id, Status::Error(8, "Phone number can't be empty"));
}
switch (type_) {
case Type::ChangePhone:
return process_send_code_result(
query_id, send_code_helper_.send_change_phone_code(phone_number, allow_flash_call, is_current_phone_number));
return process_send_code_result(query_id, send_code_helper_.send_change_phone_code(phone_number, settings));
case Type::VerifyPhone:
return process_send_code_result(
query_id, send_code_helper_.send_confirm_phone_code(phone_number, allow_flash_call, is_current_phone_number));
return process_send_code_result(query_id, send_code_helper_.send_confirm_phone_code(phone_number, settings));
case Type::ConfirmPhone:
default:
UNREACHABLE();
@ -67,7 +64,7 @@ void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number,
}
void PhoneNumberManager::set_phone_number_and_hash(uint64 query_id, string hash, string phone_number,
bool allow_flash_call, bool is_current_phone_number) {
Settings settings) {
if (phone_number.empty()) {
return on_query_error(query_id, Status::Error(8, "Phone number can't be empty"));
}
@ -77,8 +74,7 @@ void PhoneNumberManager::set_phone_number_and_hash(uint64 query_id, string hash,
switch (type_) {
case Type::ConfirmPhone:
return process_send_code_result(query_id, send_code_helper_.send_verify_phone_code(
hash, phone_number, allow_flash_call, is_current_phone_number));
return process_send_code_result(query_id, send_code_helper_.send_verify_phone_code(hash, phone_number, settings));
case Type::ChangePhone:
case Type::VerifyPhone:
default:

View File

@ -23,9 +23,10 @@ class PhoneNumberManager : public NetActor {
PhoneNumberManager(Type type, ActorShared<> parent);
void get_state(uint64 query_id);
void set_phone_number(uint64 query_id, string phone_number, bool allow_flash_call, bool is_current_phone_number);
void set_phone_number_and_hash(uint64 query_id, string hash, string phone_number, bool allow_flash_call,
bool is_current_phone_number);
using Settings = td_api::object_ptr<td_api::phoneNumberAuthenticationSettings>;
void set_phone_number(uint64 query_id, string phone_number, Settings settings);
void set_phone_number_and_hash(uint64 query_id, string hash, string phone_number, Settings settings);
void resend_authentication_code(uint64 query_id);
void check_code(uint64 query_id, string code);

View File

@ -6,6 +6,8 @@
//
#include "td/telegram/SendCodeHelper.h"
#include "td/utils/utf8.h"
namespace td {
void SendCodeHelper::on_sent_code(telegram_api::object_ptr<telegram_api::auth_sentCode> sent_code) {
@ -39,52 +41,56 @@ Result<telegram_api::auth_resendCode> SendCodeHelper::resend_code() {
return telegram_api::auth_resendCode(phone_number_, phone_code_hash_);
}
telegram_api::object_ptr<telegram_api::codeSettings> SendCodeHelper::get_input_code_settings(
bool allow_flash_call, bool is_current_phone_number) {
telegram_api::object_ptr<telegram_api::codeSettings> SendCodeHelper::get_input_code_settings(const Settings &settings) {
int32 flags = 0;
if (allow_flash_call) {
flags |= telegram_api::codeSettings::ALLOW_FLASHCALL_MASK;
}
if (is_current_phone_number) {
flags |= telegram_api::codeSettings::CURRENT_NUMBER_MASK;
string app_hash;
if (settings != nullptr) {
if (settings->allow_flash_call_) {
flags |= telegram_api::codeSettings::ALLOW_FLASHCALL_MASK;
}
if (settings->is_current_phone_number_) {
flags |= telegram_api::codeSettings::CURRENT_NUMBER_MASK;
}
if (check_utf8(settings->app_specific_sms_token_) && !settings->app_specific_sms_token_.empty()) {
app_hash = settings->app_specific_sms_token_;
} else if (check_utf8(settings->app_hash_string_) && !settings->app_hash_string_.empty()) {
flags |= telegram_api::codeSettings::APP_HASH_PERSISTENT_MASK;
app_hash = settings->app_hash_string_;
}
if (!app_hash.empty()) {
flags |= telegram_api::codeSettings::APP_HASH_MASK;
}
}
return telegram_api::make_object<telegram_api::codeSettings>(flags, false /*ignored*/, false /*ignored*/,
false /*ignored*/, string());
false /*ignored*/, app_hash);
}
Result<telegram_api::auth_sendCode> SendCodeHelper::send_code(Slice phone_number, bool allow_flash_call,
bool is_current_phone_number, int32 api_id,
const string &api_hash) {
Result<telegram_api::auth_sendCode> SendCodeHelper::send_code(Slice phone_number, const Settings &settings,
int32 api_id, const string &api_hash) {
if (!phone_number_.empty()) {
return Status::Error(8, "Can't change phone");
}
phone_number_ = phone_number.str();
return telegram_api::auth_sendCode(phone_number_, api_id, api_hash,
get_input_code_settings(allow_flash_call, is_current_phone_number));
return telegram_api::auth_sendCode(phone_number_, api_id, api_hash, get_input_code_settings(settings));
}
Result<telegram_api::account_sendChangePhoneCode> SendCodeHelper::send_change_phone_code(Slice phone_number,
bool allow_flash_call,
bool is_current_phone_number) {
const Settings &settings) {
phone_number_ = phone_number.str();
return telegram_api::account_sendChangePhoneCode(phone_number_,
get_input_code_settings(allow_flash_call, is_current_phone_number));
return telegram_api::account_sendChangePhoneCode(phone_number_, get_input_code_settings(settings));
}
Result<telegram_api::account_sendVerifyPhoneCode> SendCodeHelper::send_verify_phone_code(const string &hash,
Slice phone_number,
bool allow_flash_call,
bool is_current_phone_number) {
const Settings &settings) {
phone_number_ = phone_number.str();
return telegram_api::account_sendVerifyPhoneCode(hash,
get_input_code_settings(allow_flash_call, is_current_phone_number));
return telegram_api::account_sendVerifyPhoneCode(hash, get_input_code_settings(settings));
}
Result<telegram_api::account_sendConfirmPhoneCode> SendCodeHelper::send_confirm_phone_code(
Slice phone_number, bool allow_flash_call, bool is_current_phone_number) {
Result<telegram_api::account_sendConfirmPhoneCode> SendCodeHelper::send_confirm_phone_code(Slice phone_number,
const Settings &settings) {
phone_number_ = phone_number.str();
return telegram_api::account_sendConfirmPhoneCode(phone_number_,
get_input_code_settings(allow_flash_call, is_current_phone_number));
return telegram_api::account_sendConfirmPhoneCode(phone_number_, get_input_code_settings(settings));
}
SendCodeHelper::AuthenticationCodeInfo SendCodeHelper::get_authentication_code_info(

View File

@ -25,18 +25,19 @@ class SendCodeHelper {
td_api::object_ptr<td_api::authenticationCodeInfo> get_authentication_code_info_object() const;
Result<telegram_api::auth_resendCode> resend_code();
Result<telegram_api::auth_sendCode> send_code(Slice phone_number, bool allow_flash_call, bool is_current_phone_number,
int32 api_id, const string &api_hash);
using Settings = td_api::object_ptr<td_api::phoneNumberAuthenticationSettings>;
Result<telegram_api::account_sendChangePhoneCode> send_change_phone_code(Slice phone_number, bool allow_flash_call,
bool is_current_phone_number);
Result<telegram_api::auth_sendCode> send_code(Slice phone_number, const Settings &settings, int32 api_id,
const string &api_hash);
Result<telegram_api::account_sendChangePhoneCode> send_change_phone_code(Slice phone_number,
const Settings &settings);
Result<telegram_api::account_sendVerifyPhoneCode> send_verify_phone_code(const string &hash, Slice phone_number,
bool allow_flash_call,
bool is_current_phone_number);
const Settings &settings);
Result<telegram_api::account_sendConfirmPhoneCode> send_confirm_phone_code(Slice phone_number, bool allow_flash_call,
bool is_current_phone_number);
Result<telegram_api::account_sendConfirmPhoneCode> send_confirm_phone_code(Slice phone_number,
const Settings &settings);
Slice phone_number() const {
return phone_number_;
@ -91,8 +92,7 @@ class SendCodeHelper {
static td_api::object_ptr<td_api::AuthenticationCodeType> get_authentication_code_type_object(
const AuthenticationCodeInfo &authentication_code_info);
static telegram_api::object_ptr<telegram_api::codeSettings> get_input_code_settings(bool allow_flash_call,
bool is_current_phone_number);
static telegram_api::object_ptr<telegram_api::codeSettings> get_input_code_settings(const Settings &settings);
};
} // namespace td

View File

@ -4614,7 +4614,7 @@ void Td::on_request(uint64 id, const td_api::getAuthorizationState &request) {
void Td::on_request(uint64 id, td_api::setAuthenticationPhoneNumber &request) {
CLEAN_INPUT_STRING(request.phone_number_);
send_closure(auth_manager_actor_, &AuthManager::set_phone_number, id, std::move(request.phone_number_),
request.allow_flash_call_, request.is_current_phone_number_);
std::move(request.settings_));
}
void Td::on_request(uint64 id, const td_api::resendAuthenticationCode &request) {
@ -4842,7 +4842,7 @@ void Td::on_request(uint64 id, td_api::changePhoneNumber &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.phone_number_);
send_closure(change_phone_number_manager_, &PhoneNumberManager::set_phone_number, id,
std::move(request.phone_number_), request.allow_flash_call_, request.is_current_phone_number_);
std::move(request.phone_number_), std::move(request.settings_));
}
void Td::on_request(uint64 id, td_api::checkChangePhoneNumberCode &request) {
@ -6845,7 +6845,7 @@ void Td::on_request(uint64 id, td_api::sendPhoneNumberVerificationCode &request)
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.phone_number_);
send_closure(verify_phone_number_manager_, &PhoneNumberManager::set_phone_number, id,
std::move(request.phone_number_), request.allow_flash_call_, request.is_current_phone_number_);
std::move(request.phone_number_), std::move(request.settings_));
}
void Td::on_request(uint64 id, const td_api::resendPhoneNumberVerificationCode &request) {
@ -6924,8 +6924,7 @@ void Td::on_request(uint64 id, td_api::sendPhoneNumberConfirmationCode &request)
CLEAN_INPUT_STRING(request.phone_number_);
CLEAN_INPUT_STRING(request.hash_);
send_closure(confirm_phone_number_manager_, &PhoneNumberManager::set_phone_number_and_hash, id,
std::move(request.hash_), std::move(request.phone_number_), request.allow_flash_call_,
request.is_current_phone_number_);
std::move(request.hash_), std::move(request.phone_number_), std::move(request.settings_));
}
void Td::on_request(uint64 id, const td_api::resendPhoneNumberConfirmationCode &request) {

View File

@ -1243,7 +1243,7 @@ class CliClient final : public Actor {
if (op == "gas") {
send_request(td_api::make_object<td_api::getAuthorizationState>());
} else if (op == "sap") {
send_request(td_api::make_object<td_api::setAuthenticationPhoneNumber>(args, false, false));
send_request(td_api::make_object<td_api::setAuthenticationPhoneNumber>(args, nullptr));
} else if (op == "rac") {
send_request(td_api::make_object<td_api::resendAuthenticationCode>());
} else if (op == "cdek" || op == "CheckDatabaseEncryptionKey") {
@ -1365,7 +1365,7 @@ class CliClient final : public Actor {
} else if (op == "gpcl") {
send_request(td_api::make_object<td_api::getPreferredCountryLanguage>(args));
} else if (op == "spnvc" || op == "SendPhoneNumberVerificationCode") {
send_request(td_api::make_object<td_api::sendPhoneNumberVerificationCode>(args, false, false));
send_request(td_api::make_object<td_api::sendPhoneNumberVerificationCode>(args, nullptr));
} else if (op == "cpnvc" || op == "CheckPhoneNumberVerificationCode") {
send_request(td_api::make_object<td_api::checkPhoneNumberVerificationCode>(args));
} else if (op == "rpnvc" || op == "ResendPhoneNumberVerificationCode") {
@ -1388,7 +1388,7 @@ class CliClient final : public Actor {
} else if (op == "rreac") {
send_request(td_api::make_object<td_api::resendRecoveryEmailAddressCode>());
} else if (op == "spncc") {
send_request(td_api::make_object<td_api::sendPhoneNumberVerificationCode>(args, false, false));
send_request(td_api::make_object<td_api::sendPhoneNumberVerificationCode>(args, nullptr));
} else if (op == "cpncc") {
send_request(td_api::make_object<td_api::checkPhoneNumberVerificationCode>(args));
} else if (op == "rpncc") {
@ -1530,7 +1530,7 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::setUserPrivacySettingRules>(
get_user_privacy_setting(setting), td_api::make_object<td_api::userPrivacySettingRules>(std::move(rules))));
} else if (op == "cp" || op == "ChangePhone") {
send_request(td_api::make_object<td_api::changePhoneNumber>(args, false, false));
send_request(td_api::make_object<td_api::changePhoneNumber>(args, nullptr));
} else if (op == "ccpc" || op == "CheckChangePhoneCode") {
send_request(td_api::make_object<td_api::checkChangePhoneNumberCode>(args));
} else if (op == "rcpc" || op == "ResendChangePhoneCode") {

View File

@ -212,7 +212,7 @@ class DoAuthentication : public Task {
function = make_tl_object<td_api::checkDatabaseEncryptionKey>();
break;
case td_api::authorizationStateWaitPhoneNumber::ID:
function = make_tl_object<td_api::setAuthenticationPhoneNumber>(phone_, false, true);
function = make_tl_object<td_api::setAuthenticationPhoneNumber>(phone_, nullptr);
break;
case td_api::authorizationStateWaitCode::ID:
function = make_tl_object<td_api::checkAuthenticationCode>(code_, name_, "");