Remove authorization loss logic from DcAuthManager, because we can be logged before entering password and before authorization.
This commit is contained in:
parent
ad0c5e6783
commit
90b34e7d0c
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
|
||||||
#include "td/telegram/ConfigShared.h"
|
|
||||||
#include "td/telegram/Global.h"
|
#include "td/telegram/Global.h"
|
||||||
#include "td/telegram/net/AuthDataShared.h"
|
#include "td/telegram/net/AuthDataShared.h"
|
||||||
#include "td/telegram/net/NetQuery.h"
|
#include "td/telegram/net/NetQuery.h"
|
||||||
@ -66,9 +65,7 @@ void DcAuthManager::add_dc(std::shared_ptr<AuthDataShared> auth_data) {
|
|||||||
info.shared_auth_data = std::move(auth_data);
|
info.shared_auth_data = std::move(auth_data);
|
||||||
auto state_was_auth = info.shared_auth_data->get_auth_key_state();
|
auto state_was_auth = info.shared_auth_data->get_auth_key_state();
|
||||||
info.auth_key_state = state_was_auth.first;
|
info.auth_key_state = state_was_auth.first;
|
||||||
VLOG(dc) << "Add " << info.dc_id << " with auth key state " << info.auth_key_state
|
VLOG(dc) << "Add " << info.dc_id << " with auth key state " << info.auth_key_state;
|
||||||
<< " and was_auth = " << state_was_auth.second;
|
|
||||||
was_auth_ |= state_was_auth.second;
|
|
||||||
if (!main_dc_id_.is_exact()) {
|
if (!main_dc_id_.is_exact()) {
|
||||||
main_dc_id_ = info.dc_id;
|
main_dc_id_ = info.dc_id;
|
||||||
VLOG(dc) << "Set main DcId to " << main_dc_id_;
|
VLOG(dc) << "Set main DcId to " << main_dc_id_;
|
||||||
@ -101,10 +98,8 @@ void DcAuthManager::update_auth_key_state() {
|
|||||||
int32 dc_id = narrow_cast<int32>(get_link_token());
|
int32 dc_id = narrow_cast<int32>(get_link_token());
|
||||||
auto &dc = get_dc(dc_id);
|
auto &dc = get_dc(dc_id);
|
||||||
auto state_was_auth = dc.shared_auth_data->get_auth_key_state();
|
auto state_was_auth = dc.shared_auth_data->get_auth_key_state();
|
||||||
VLOG(dc) << "Update " << dc_id << " auth key state from " << dc.auth_key_state << " to " << state_was_auth.first
|
VLOG(dc) << "Update " << dc_id << " auth key state from " << dc.auth_key_state << " to " << state_was_auth.first;
|
||||||
<< " with was_auth = " << state_was_auth.second;
|
|
||||||
dc.auth_key_state = state_was_auth.first;
|
dc.auth_key_state = state_was_auth.first;
|
||||||
was_auth_ |= state_was_auth.second;
|
|
||||||
|
|
||||||
loop();
|
loop();
|
||||||
}
|
}
|
||||||
@ -239,15 +234,8 @@ void DcAuthManager::loop() {
|
|||||||
}
|
}
|
||||||
auto main_dc = find_dc(main_dc_id_.get_raw_id());
|
auto main_dc = find_dc(main_dc_id_.get_raw_id());
|
||||||
if (!main_dc || main_dc->auth_key_state != AuthKeyState::OK) {
|
if (!main_dc || main_dc->auth_key_state != AuthKeyState::OK) {
|
||||||
VLOG(dc) << "Main is " << main_dc_id_ << ", main auth key state is "
|
VLOG(dc) << "Skip loop, because main DC is " << main_dc_id_ << ", main auth key state is "
|
||||||
<< (main_dc ? main_dc->auth_key_state : AuthKeyState::Empty) << ", was_auth = " << was_auth_;
|
<< (main_dc != nullptr ? main_dc->auth_key_state : AuthKeyState::Empty);
|
||||||
if (was_auth_) {
|
|
||||||
G()->shared_config().set_option_boolean("auth", false);
|
|
||||||
destroy_loop();
|
|
||||||
}
|
|
||||||
VLOG(dc) << "Skip loop because auth state of main DcId " << main_dc_id_.get_raw_id() << " is "
|
|
||||||
<< (main_dc != nullptr ? (PSTRING() << main_dc->auth_key_state) : "unknown");
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (auto &dc : dcs_) {
|
for (auto &dc : dcs_) {
|
||||||
|
@ -47,7 +47,6 @@ class DcAuthManager : public NetQueryCallback {
|
|||||||
ActorShared<> parent_;
|
ActorShared<> parent_;
|
||||||
|
|
||||||
std::vector<DcInfo> dcs_;
|
std::vector<DcInfo> dcs_;
|
||||||
bool was_auth_{false};
|
|
||||||
DcId main_dc_id_;
|
DcId main_dc_id_;
|
||||||
bool close_flag_{false};
|
bool close_flag_{false};
|
||||||
Promise<> destroy_promise_;
|
Promise<> destroy_promise_;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "td/telegram/telegram_api.h"
|
#include "td/telegram/telegram_api.h"
|
||||||
|
|
||||||
|
#include "td/telegram/ConfigShared.h"
|
||||||
#include "td/telegram/DhCache.h"
|
#include "td/telegram/DhCache.h"
|
||||||
#include "td/telegram/Global.h"
|
#include "td/telegram/Global.h"
|
||||||
#include "td/telegram/net/DcAuthManager.h"
|
#include "td/telegram/net/DcAuthManager.h"
|
||||||
@ -778,6 +779,7 @@ void Session::on_message_result_error(uint64 id, int error_code, BufferSlice mes
|
|||||||
LOG(WARNING) << "Lost authorization due to " << tag("msg", message.as_slice());
|
LOG(WARNING) << "Lost authorization due to " << tag("msg", message.as_slice());
|
||||||
}
|
}
|
||||||
auth_data_.set_auth_flag(false);
|
auth_data_.set_auth_flag(false);
|
||||||
|
G()->shared_config().set_option_boolean("auth", false);
|
||||||
shared_auth_data_->set_auth_key(auth_data_.get_main_auth_key());
|
shared_auth_data_->set_auth_key(auth_data_.get_main_auth_key());
|
||||||
on_session_failed(Status::OK());
|
on_session_failed(Status::OK());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user