Remove "auth" internal option.

This commit is contained in:
levlam 2022-08-17 20:01:03 +03:00
parent 2ebeca31ca
commit f9161dccc3
5 changed files with 14 additions and 8 deletions

View File

@ -720,6 +720,10 @@ void AuthManager::on_authorization_lost(string source) {
LOG(INFO) << "Ignore authorization loss because of " << source << ", while logging out";
return;
}
if (state_ == State::Closing || state_ == State::DestroyingKeys) {
LOG(INFO) << "Ignore duplicate authorization loss because of " << source;
return;
}
LOG(WARNING) << "Lost authorization because of " << source;
destroy_auth_keys();
}

View File

@ -6,6 +6,7 @@
//
#include "td/telegram/Global.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ConfigShared.h"
#include "td/telegram/net/ConnectionCreator.h"
#include "td/telegram/net/NetQueryDispatcher.h"
@ -29,9 +30,7 @@ Global::Global() = default;
Global::~Global() = default;
void Global::log_out(Slice reason) {
if (!have_option("auth")) {
set_option_string("auth", reason);
}
send_closure(auth_manager_, &AuthManager::on_authorization_lost, reason.str());
}
void Global::close_all(Promise<> on_finished) {

View File

@ -34,6 +34,7 @@ namespace td {
class AnimationsManager;
class AttachMenuManager;
class AuthManager;
class BackgroundManager;
class CallManager;
class ConfigManager;
@ -206,6 +207,10 @@ class Global final : public ActorContext {
attach_menu_manager_ = attach_menu_manager;
}
void set_auth_manager(ActorId<AuthManager> auth_manager) {
auth_manager_ = auth_manager;
}
ActorId<BackgroundManager> background_manager() const {
return background_manager_;
}
@ -479,6 +484,7 @@ class Global final : public ActorContext {
ActorId<Td> td_;
ActorId<AnimationsManager> animations_manager_;
ActorId<AttachMenuManager> attach_menu_manager_;
ActorId<AuthManager> auth_manager_;
ActorId<BackgroundManager> background_manager_;
ActorId<CallManager> call_manager_;
ActorId<ConfigManager> config_manager_;

View File

@ -128,8 +128,7 @@ bool OptionManager::is_internal_option(Slice name) {
switch (name[0]) {
case 'a':
return name == "about_length_limit_default" || name == "about_length_limit_premium" ||
name == "animated_emoji_zoom" || name == "animation_search_emojis" ||
name == "animation_search_provider" || name == "auth";
name == "animated_emoji_zoom" || name == "animation_search_emojis" || name == "animation_search_provider";
case 'b':
return name == "base_language_pack_version";
case 'c':
@ -201,9 +200,6 @@ void OptionManager::on_option_updated(const string &name) {
if (name == "animation_search_provider") {
td_->animations_manager_->on_update_animation_search_provider(G()->get_option_string(name));
}
if (name == "auth") {
send_closure(td_->auth_manager_actor_, &AuthManager::on_authorization_lost, G()->get_option_string(name));
}
break;
case 'b':
if (name == "base_language_pack_version") {

View File

@ -3674,6 +3674,7 @@ void Td::init(Result<TdDb::OpenedDatabase> r_opened_database) {
VLOG(td_init) << "Create AuthManager";
auth_manager_ = td::make_unique<AuthManager>(parameters_.api_id, parameters_.api_hash, create_reference());
auth_manager_actor_ = register_actor("AuthManager", auth_manager_.get());
G()->set_auth_manager(auth_manager_actor_.get());
init_file_manager();