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::cerr << "Enter phone number: ";
std::string phone_number; std::string phone_number;
std::cin >> phone_number; std::cin >> phone_number;
send_query(td_api::make_object<td_api::setAuthenticationPhoneNumber>( send_query(td_api::make_object<td_api::setAuthenticationPhoneNumber>(phone_number, nullptr),
phone_number, false /*allow_flash_calls*/, false /*is_current_phone_number*/),
create_authentication_query_handler()); create_authentication_query_handler());
}, },
[this](td_api::authorizationStateWaitEncryptionKey &) { [this](td_api::authorizationStateWaitEncryptionKey &) {

View File

@ -93,7 +93,7 @@ namespace TdExample
else if (_authorizationState is TdApi.AuthorizationStateWaitPhoneNumber) else if (_authorizationState is TdApi.AuthorizationStateWaitPhoneNumber)
{ {
string phoneNumber = ReadLine("Please enter phone number: "); 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) else if (_authorizationState is TdApi.AuthorizationStateWaitCode)
{ {

View File

@ -108,7 +108,7 @@ public final class Example {
break; break;
case TdApi.AuthorizationStateWaitPhoneNumber.CONSTRUCTOR: { case TdApi.AuthorizationStateWaitPhoneNumber.CONSTRUCTOR: {
String phoneNumber = promptString("Please enter phone number: "); 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; break;
} }
case TdApi.AuthorizationStateWaitCode.CONSTRUCTOR: { case TdApi.AuthorizationStateWaitCode.CONSTRUCTOR: {

View File

@ -94,7 +94,7 @@ namespace TdApp
{ {
var args = command.Split(" ".ToCharArray(), 2); var args = command.Split(" ".ToCharArray(), 2);
AcceptCommand(command); 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")) 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; 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 //@description Represents a list of animations @animations List of animations
animations animations:vector<animation> = 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 //@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; 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 //@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 //-or if there is no pending authentication query and the current authorization state is authorizationStateWaitCode or authorizationStateWaitPassword
setAuthenticationPhoneNumber phone_number:string allow_flash_call:Bool is_current_phone_number:Bool = Ok; //@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 //@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; 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 //@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; 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 //-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; setRecoveryEmailAddress password:string new_recovery_email_address:string = PasswordState;
@ -3480,8 +3489,8 @@ setBio bio:string = Ok;
setUsername username: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 //@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 //@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 allow_flash_call:Bool is_current_phone_number:Bool = AuthenticationCodeInfo; 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 //@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; 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 //@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 //@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 allow_flash_call:Bool is_current_phone_number:Bool = AuthenticationCodeInfo; 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 //@description Re-sends the code to verify a phone number to be added to a user's Telegram Passport
resendPhoneNumberVerificationCode = AuthenticationCodeInfo; 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 //@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 //@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 allow_flash_call:Bool is_current_phone_number:Bool = AuthenticationCodeInfo; sendPhoneNumberConfirmationCode hash:string phone_number:string settings:phoneNumberAuthenticationSettings = AuthenticationCodeInfo;
//@description Resends phone number confirmation code //@description Resends phone number confirmation code
resendPhoneNumberConfirmationCode = AuthenticationCodeInfo; 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)); DcId::main(), NetQuery::Type::Common, NetQuery::AuthFlag::Off));
} }
void AuthManager::set_phone_number(uint64 query_id, string phone_number, bool allow_flash_call, void AuthManager::set_phone_number(uint64 query_id, string phone_number,
bool is_current_phone_number) { td_api::object_ptr<td_api::phoneNumberAuthenticationSettings> settings) {
if (state_ != State::WaitPhoneNumber) { if (state_ != State::WaitPhoneNumber) {
if ((state_ == State::WaitCode || state_ == State::WaitPassword) && net_query_id_ == 0) { if ((state_ == State::WaitCode || state_ == State::WaitPassword) && net_query_id_ == 0) {
// ok // 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")); return on_query_error(query_id, Status::Error(8, "Phone number can't be empty"));
} }
auto r_send_code = auto r_send_code = send_code_helper_.send_code(phone_number, settings, api_id_, api_hash_);
send_code_helper_.send_code(phone_number, allow_flash_call, is_current_phone_number, api_id_, api_hash_);
if (r_send_code.is_error()) { if (r_send_code.is_error()) {
send_code_helper_ = SendCodeHelper(); send_code_helper_ = SendCodeHelper();
terms_of_service_ = TermsOfService(); terms_of_service_ = TermsOfService();
r_send_code = r_send_code = send_code_helper_.send_code(phone_number, settings, api_id_, api_hash_);
send_code_helper_.send_code(phone_number, allow_flash_call, is_current_phone_number, api_id_, api_hash_);
if (r_send_code.is_error()) { if (r_send_code.is_error()) {
return on_query_error(query_id, r_send_code.move_as_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; bool is_authorized() const;
void get_state(uint64 query_id); 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 resend_authentication_code(uint64 query_id);
void check_code(uint64 query_id, string code, string first_name, string last_name); void check_code(uint64 query_id, string code, string first_name, string last_name);
void check_bot_token(uint64 query_id, string bot_token); 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()))); 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, void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number, Settings settings) {
bool is_current_phone_number) {
if (phone_number.empty()) { if (phone_number.empty()) {
return on_query_error(query_id, Status::Error(8, "Phone number can't be empty")); return on_query_error(query_id, Status::Error(8, "Phone number can't be empty"));
} }
switch (type_) { switch (type_) {
case Type::ChangePhone: case Type::ChangePhone:
return process_send_code_result( return process_send_code_result(query_id, send_code_helper_.send_change_phone_code(phone_number, settings));
query_id, send_code_helper_.send_change_phone_code(phone_number, allow_flash_call, is_current_phone_number));
case Type::VerifyPhone: case Type::VerifyPhone:
return process_send_code_result( return process_send_code_result(query_id, send_code_helper_.send_confirm_phone_code(phone_number, settings));
query_id, send_code_helper_.send_confirm_phone_code(phone_number, allow_flash_call, is_current_phone_number));
case Type::ConfirmPhone: case Type::ConfirmPhone:
default: default:
UNREACHABLE(); 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, 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()) { if (phone_number.empty()) {
return on_query_error(query_id, Status::Error(8, "Phone number can't be 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_) { switch (type_) {
case Type::ConfirmPhone: case Type::ConfirmPhone:
return process_send_code_result(query_id, send_code_helper_.send_verify_phone_code( return process_send_code_result(query_id, send_code_helper_.send_verify_phone_code(hash, phone_number, settings));
hash, phone_number, allow_flash_call, is_current_phone_number));
case Type::ChangePhone: case Type::ChangePhone:
case Type::VerifyPhone: case Type::VerifyPhone:
default: default:

View File

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

View File

@ -6,6 +6,8 @@
// //
#include "td/telegram/SendCodeHelper.h" #include "td/telegram/SendCodeHelper.h"
#include "td/utils/utf8.h"
namespace td { namespace td {
void SendCodeHelper::on_sent_code(telegram_api::object_ptr<telegram_api::auth_sentCode> sent_code) { 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_); return telegram_api::auth_resendCode(phone_number_, phone_code_hash_);
} }
telegram_api::object_ptr<telegram_api::codeSettings> SendCodeHelper::get_input_code_settings( telegram_api::object_ptr<telegram_api::codeSettings> SendCodeHelper::get_input_code_settings(const Settings &settings) {
bool allow_flash_call, bool is_current_phone_number) {
int32 flags = 0; int32 flags = 0;
if (allow_flash_call) { string app_hash;
flags |= telegram_api::codeSettings::ALLOW_FLASHCALL_MASK; if (settings != nullptr) {
} if (settings->allow_flash_call_) {
if (is_current_phone_number) { flags |= telegram_api::codeSettings::ALLOW_FLASHCALL_MASK;
flags |= telegram_api::codeSettings::CURRENT_NUMBER_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*/, 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, Result<telegram_api::auth_sendCode> SendCodeHelper::send_code(Slice phone_number, const Settings &settings,
bool is_current_phone_number, int32 api_id, int32 api_id, const string &api_hash) {
const string &api_hash) {
if (!phone_number_.empty()) { if (!phone_number_.empty()) {
return Status::Error(8, "Can't change phone"); return Status::Error(8, "Can't change phone");
} }
phone_number_ = phone_number.str(); phone_number_ = phone_number.str();
return telegram_api::auth_sendCode(phone_number_, api_id, api_hash, return telegram_api::auth_sendCode(phone_number_, api_id, api_hash, get_input_code_settings(settings));
get_input_code_settings(allow_flash_call, is_current_phone_number));
} }
Result<telegram_api::account_sendChangePhoneCode> SendCodeHelper::send_change_phone_code(Slice phone_number, Result<telegram_api::account_sendChangePhoneCode> SendCodeHelper::send_change_phone_code(Slice phone_number,
bool allow_flash_call, const Settings &settings) {
bool is_current_phone_number) {
phone_number_ = phone_number.str(); phone_number_ = phone_number.str();
return telegram_api::account_sendChangePhoneCode(phone_number_, return telegram_api::account_sendChangePhoneCode(phone_number_, get_input_code_settings(settings));
get_input_code_settings(allow_flash_call, is_current_phone_number));
} }
Result<telegram_api::account_sendVerifyPhoneCode> SendCodeHelper::send_verify_phone_code(const string &hash, Result<telegram_api::account_sendVerifyPhoneCode> SendCodeHelper::send_verify_phone_code(const string &hash,
Slice phone_number, Slice phone_number,
bool allow_flash_call, const Settings &settings) {
bool is_current_phone_number) {
phone_number_ = phone_number.str(); phone_number_ = phone_number.str();
return telegram_api::account_sendVerifyPhoneCode(hash, return telegram_api::account_sendVerifyPhoneCode(hash, get_input_code_settings(settings));
get_input_code_settings(allow_flash_call, is_current_phone_number));
} }
Result<telegram_api::account_sendConfirmPhoneCode> SendCodeHelper::send_confirm_phone_code( Result<telegram_api::account_sendConfirmPhoneCode> SendCodeHelper::send_confirm_phone_code(Slice phone_number,
Slice phone_number, bool allow_flash_call, bool is_current_phone_number) { const Settings &settings) {
phone_number_ = phone_number.str(); phone_number_ = phone_number.str();
return telegram_api::account_sendConfirmPhoneCode(phone_number_, return telegram_api::account_sendConfirmPhoneCode(phone_number_, get_input_code_settings(settings));
get_input_code_settings(allow_flash_call, is_current_phone_number));
} }
SendCodeHelper::AuthenticationCodeInfo SendCodeHelper::get_authentication_code_info( 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; td_api::object_ptr<td_api::authenticationCodeInfo> get_authentication_code_info_object() const;
Result<telegram_api::auth_resendCode> resend_code(); 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, using Settings = td_api::object_ptr<td_api::phoneNumberAuthenticationSettings>;
int32 api_id, const string &api_hash);
Result<telegram_api::account_sendChangePhoneCode> send_change_phone_code(Slice phone_number, bool allow_flash_call, Result<telegram_api::auth_sendCode> send_code(Slice phone_number, const Settings &settings, int32 api_id,
bool is_current_phone_number); 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, Result<telegram_api::account_sendVerifyPhoneCode> send_verify_phone_code(const string &hash, Slice phone_number,
bool allow_flash_call, const Settings &settings);
bool is_current_phone_number);
Result<telegram_api::account_sendConfirmPhoneCode> send_confirm_phone_code(Slice phone_number, bool allow_flash_call, Result<telegram_api::account_sendConfirmPhoneCode> send_confirm_phone_code(Slice phone_number,
bool is_current_phone_number); const Settings &settings);
Slice phone_number() const { Slice phone_number() const {
return phone_number_; return phone_number_;
@ -91,8 +92,7 @@ class SendCodeHelper {
static td_api::object_ptr<td_api::AuthenticationCodeType> get_authentication_code_type_object( static td_api::object_ptr<td_api::AuthenticationCodeType> get_authentication_code_type_object(
const AuthenticationCodeInfo &authentication_code_info); const AuthenticationCodeInfo &authentication_code_info);
static telegram_api::object_ptr<telegram_api::codeSettings> get_input_code_settings(bool allow_flash_call, static telegram_api::object_ptr<telegram_api::codeSettings> get_input_code_settings(const Settings &settings);
bool is_current_phone_number);
}; };
} // namespace td } // 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) { void Td::on_request(uint64 id, td_api::setAuthenticationPhoneNumber &request) {
CLEAN_INPUT_STRING(request.phone_number_); CLEAN_INPUT_STRING(request.phone_number_);
send_closure(auth_manager_actor_, &AuthManager::set_phone_number, id, std::move(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) { 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(); CHECK_IS_USER();
CLEAN_INPUT_STRING(request.phone_number_); CLEAN_INPUT_STRING(request.phone_number_);
send_closure(change_phone_number_manager_, &PhoneNumberManager::set_phone_number, id, 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) { 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(); CHECK_IS_USER();
CLEAN_INPUT_STRING(request.phone_number_); CLEAN_INPUT_STRING(request.phone_number_);
send_closure(verify_phone_number_manager_, &PhoneNumberManager::set_phone_number, id, 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) { 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.phone_number_);
CLEAN_INPUT_STRING(request.hash_); CLEAN_INPUT_STRING(request.hash_);
send_closure(confirm_phone_number_manager_, &PhoneNumberManager::set_phone_number_and_hash, id, 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_, std::move(request.hash_), std::move(request.phone_number_), std::move(request.settings_));
request.is_current_phone_number_);
} }
void Td::on_request(uint64 id, const td_api::resendPhoneNumberConfirmationCode &request) { 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") { if (op == "gas") {
send_request(td_api::make_object<td_api::getAuthorizationState>()); send_request(td_api::make_object<td_api::getAuthorizationState>());
} else if (op == "sap") { } 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") { } else if (op == "rac") {
send_request(td_api::make_object<td_api::resendAuthenticationCode>()); send_request(td_api::make_object<td_api::resendAuthenticationCode>());
} else if (op == "cdek" || op == "CheckDatabaseEncryptionKey") { } else if (op == "cdek" || op == "CheckDatabaseEncryptionKey") {
@ -1365,7 +1365,7 @@ class CliClient final : public Actor {
} else if (op == "gpcl") { } else if (op == "gpcl") {
send_request(td_api::make_object<td_api::getPreferredCountryLanguage>(args)); send_request(td_api::make_object<td_api::getPreferredCountryLanguage>(args));
} else if (op == "spnvc" || op == "SendPhoneNumberVerificationCode") { } 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") { } else if (op == "cpnvc" || op == "CheckPhoneNumberVerificationCode") {
send_request(td_api::make_object<td_api::checkPhoneNumberVerificationCode>(args)); send_request(td_api::make_object<td_api::checkPhoneNumberVerificationCode>(args));
} else if (op == "rpnvc" || op == "ResendPhoneNumberVerificationCode") { } else if (op == "rpnvc" || op == "ResendPhoneNumberVerificationCode") {
@ -1388,7 +1388,7 @@ class CliClient final : public Actor {
} else if (op == "rreac") { } else if (op == "rreac") {
send_request(td_api::make_object<td_api::resendRecoveryEmailAddressCode>()); send_request(td_api::make_object<td_api::resendRecoveryEmailAddressCode>());
} else if (op == "spncc") { } 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") { } else if (op == "cpncc") {
send_request(td_api::make_object<td_api::checkPhoneNumberVerificationCode>(args)); send_request(td_api::make_object<td_api::checkPhoneNumberVerificationCode>(args));
} else if (op == "rpncc") { } else if (op == "rpncc") {
@ -1530,7 +1530,7 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::setUserPrivacySettingRules>( send_request(td_api::make_object<td_api::setUserPrivacySettingRules>(
get_user_privacy_setting(setting), td_api::make_object<td_api::userPrivacySettingRules>(std::move(rules)))); get_user_privacy_setting(setting), td_api::make_object<td_api::userPrivacySettingRules>(std::move(rules))));
} else if (op == "cp" || op == "ChangePhone") { } 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") { } else if (op == "ccpc" || op == "CheckChangePhoneCode") {
send_request(td_api::make_object<td_api::checkChangePhoneNumberCode>(args)); send_request(td_api::make_object<td_api::checkChangePhoneNumberCode>(args));
} else if (op == "rcpc" || op == "ResendChangePhoneCode") { } else if (op == "rcpc" || op == "ResendChangePhoneCode") {

View File

@ -212,7 +212,7 @@ class DoAuthentication : public Task {
function = make_tl_object<td_api::checkDatabaseEncryptionKey>(); function = make_tl_object<td_api::checkDatabaseEncryptionKey>();
break; break;
case td_api::authorizationStateWaitPhoneNumber::ID: 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; break;
case td_api::authorizationStateWaitCode::ID: case td_api::authorizationStateWaitCode::ID:
function = make_tl_object<td_api::checkAuthenticationCode>(code_, name_, ""); function = make_tl_object<td_api::checkAuthenticationCode>(code_, name_, "");