Skip to content

Commit

Permalink
Auto log in if password was removed just after code checking.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: f01d53b5d93ec20690a4099d8be1d60d6b9ca3c1
  • Loading branch information
levlam committed Aug 12, 2018
1 parent 4404267 commit 8283d04
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions td/telegram/AuthManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ void AuthManager::check_code(uint64 query_id, string code, string first_name, st
return on_query_error(query_id, Status::Error(8, "checkAuthenticationCode unexpected"));
}

code_ = code;
on_new_query(query_id);
if (send_code_helper_.phone_registered() || first_name.empty()) {
start_net_query(NetQueryType::SignIn,
Expand Down Expand Up @@ -748,13 +749,13 @@ void AuthManager::on_get_password_result(NetQueryPtr &result) {
return on_query_error(r_password.move_as_error());
}
auto password = r_password.move_as_ok();
LOG(INFO) << "Receive password info: " << to_string(password);

wait_password_state_ = WaitPasswordState();
if (password->current_algo_ != nullptr) {
switch (password->current_algo_->get_id()) {
case telegram_api::passwordKdfAlgoUnknown::ID:
// TODO we need to abort authorization somehow
break;
return on_query_error(Status::Error(400, "Application update is needed to log in"));
case telegram_api::passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow::ID: {
auto algo = move_tl_object_as<telegram_api::passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow>(
password->current_algo_);
Expand All @@ -773,7 +774,12 @@ void AuthManager::on_get_password_result(NetQueryPtr &result) {
UNREACHABLE();
}
} else {
// TODO we need to resend auth_signIn instead of going to WaitPassword state
start_net_query(NetQueryType::SignIn,
G()->net_query_creator().create(
create_storer(telegram_api::auth_signIn(send_code_helper_.phone_number().str(),
send_code_helper_.phone_code_hash().str(), code_)),
DcId::main(), NetQuery::Type::Common, NetQuery::AuthFlag::Off));
return;
}

update_state(State::WaitPassword);
Expand Down
1 change: 1 addition & 0 deletions td/telegram/AuthManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ class AuthManager : public NetActor {

// State::WaitCode
SendCodeHelper send_code_helper_;
string code_;
TermsOfService terms_of_service_;

// for bots
Expand Down
1 change: 1 addition & 0 deletions td/telegram/ContactsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6482,6 +6482,7 @@ void ContactsManager::on_get_chats(vector<tl_object_ptr<telegram_api::Chat>> &&c
}

void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&chat_full_ptr) {
LOG(INFO) << "Receive " << to_string(chat_full_ptr);
if (chat_full_ptr->get_id() == telegram_api::chatFull::ID) {
auto chat_full = move_tl_object_as<telegram_api::chatFull>(chat_full_ptr);
ChatId chat_id(chat_full->id_);
Expand Down

0 comments on commit 8283d04

Please sign in to comment.