Double check authorization during start up
This commit is contained in:
parent
3886cc9c13
commit
449974d425
@ -59,6 +59,7 @@ AuthManager::AuthManager(int32 api_id, const string &api_hash, ActorShared<> par
|
||||
ContactsManager::send_get_me_query(
|
||||
td_, PromiseCreator::lambda([this](Result<Unit> result) { update_state(State::Ok); }));
|
||||
}
|
||||
G()->net_query_dispatcher().check_authorization_is_ok();
|
||||
} else if (auth_str == "logout") {
|
||||
LOG(WARNING) << "Continue to log out";
|
||||
update_state(State::LoggingOut);
|
||||
|
@ -6,6 +6,7 @@
|
||||
//
|
||||
#include "td/telegram/net/DcAuthManager.h"
|
||||
|
||||
#include "td/telegram/ConfigShared.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/net/AuthDataShared.h"
|
||||
#include "td/telegram/net/NetQuery.h"
|
||||
@ -240,4 +241,11 @@ void DcAuthManager::loop() {
|
||||
}
|
||||
}
|
||||
|
||||
void DcAuthManager::check_authorization_is_ok() {
|
||||
auto main_dc = find_dc(main_dc_id_.get_raw_id());
|
||||
if (!main_dc || main_dc->auth_key_state != AuthKeyState::OK) {
|
||||
G()->shared_config().set_option_string("auth", "Authorization check failed in DcAuthManager");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -31,6 +31,8 @@ class DcAuthManager final : public NetQueryCallback {
|
||||
void update_main_dc(DcId new_main_dc_id);
|
||||
void destroy(Promise<> promise);
|
||||
|
||||
void check_authorization_is_ok();
|
||||
|
||||
private:
|
||||
struct DcInfo {
|
||||
DcId dc_id;
|
||||
|
@ -352,4 +352,8 @@ void NetQueryDispatcher::set_main_dc_id(int32 new_main_dc_id) {
|
||||
G()->td_db()->get_binlog_pmc()->set("main_dc_id", to_string(main_dc_id_.load(std::memory_order_relaxed)));
|
||||
}
|
||||
|
||||
void NetQueryDispatcher::check_authorization_is_ok() {
|
||||
send_closure(dc_auth_manager_, &DcAuthManager::check_authorization_is_ok);
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -58,6 +58,7 @@ class NetQueryDispatcher {
|
||||
}
|
||||
|
||||
void set_main_dc_id(int32 new_main_dc_id);
|
||||
void check_authorization_is_ok();
|
||||
|
||||
private:
|
||||
std::atomic<bool> stop_flag_{false};
|
||||
|
Loading…
Reference in New Issue
Block a user