diff --git a/td/telegram/PhoneNumberManager.cpp b/td/telegram/PhoneNumberManager.cpp index 835ba1911..4c8742efd 100644 --- a/td/telegram/PhoneNumberManager.cpp +++ b/td/telegram/PhoneNumberManager.cpp @@ -213,6 +213,14 @@ void PhoneNumberManager::on_send_code_result(NetQueryPtr &result) { LOG(INFO) << "Receive " << to_string(sent_code); + switch (sent_code->type_->get_id()) { + case telegram_api::auth_sentCodeTypeSetUpEmailRequired::ID: + case telegram_api::auth_sentCodeTypeEmailCode::ID: + return on_query_error(Status::Error(500, "Receive incorrect response")); + default: + break; + } + send_code_helper_.on_sent_code(std::move(sent_code)); state_ = State::WaitCode; diff --git a/td/telegram/SendCodeHelper.cpp b/td/telegram/SendCodeHelper.cpp index 993268f05..989e2a8f0 100644 --- a/td/telegram/SendCodeHelper.cpp +++ b/td/telegram/SendCodeHelper.cpp @@ -13,7 +13,7 @@ namespace td { void SendCodeHelper::on_sent_code(telegram_api::object_ptr sent_code) { phone_code_hash_ = std::move(sent_code->phone_code_hash_); - sent_code_info_ = get_authentication_code_info(std::move(sent_code->type_)); + sent_code_info_ = get_sent_authentication_code_info(std::move(sent_code->type_)); next_code_info_ = get_authentication_code_info(std::move(sent_code->next_type_)); next_code_timestamp_ = Timestamp::in((sent_code->flags_ & SENT_CODE_FLAG_HAS_TIMEOUT) != 0 ? sent_code->timeout_ : 0); } @@ -124,7 +124,7 @@ SendCodeHelper::AuthenticationCodeInfo SendCodeHelper::get_authentication_code_i } } -SendCodeHelper::AuthenticationCodeInfo SendCodeHelper::get_authentication_code_info( +SendCodeHelper::AuthenticationCodeInfo SendCodeHelper::get_sent_authentication_code_info( tl_object_ptr &&sent_code_type_ptr) { CHECK(sent_code_type_ptr != nullptr); switch (sent_code_type_ptr->get_id()) { @@ -151,7 +151,6 @@ SendCodeHelper::AuthenticationCodeInfo SendCodeHelper::get_authentication_code_i } case telegram_api::auth_sentCodeTypeEmailCode::ID: case telegram_api::auth_sentCodeTypeSetUpEmailRequired::ID: - return AuthenticationCodeInfo(); default: UNREACHABLE(); return AuthenticationCodeInfo(); diff --git a/td/telegram/SendCodeHelper.h b/td/telegram/SendCodeHelper.h index 6ace7fad4..e4cff30c4 100644 --- a/td/telegram/SendCodeHelper.h +++ b/td/telegram/SendCodeHelper.h @@ -87,7 +87,7 @@ class SendCodeHelper { static AuthenticationCodeInfo get_authentication_code_info( tl_object_ptr &&code_type_ptr); - static AuthenticationCodeInfo get_authentication_code_info( + static AuthenticationCodeInfo get_sent_authentication_code_info( tl_object_ptr &&sent_code_type_ptr); static td_api::object_ptr get_authentication_code_type_object(