diff --git a/td/telegram/AuthManager.cpp b/td/telegram/AuthManager.cpp index bd23636c..d23dec7b 100644 --- a/td/telegram/AuthManager.cpp +++ b/td/telegram/AuthManager.cpp @@ -883,7 +883,21 @@ bool AuthManager::load_state() { LOG(INFO) << "Ignore auth_state: timestamp in the future"; return false; } - if (Timestamp::at(db_state.state_timestamp_.at() + 5 * 60).is_in_past()) { + auto state_timeout = [state = db_state.state_] { + switch (state) { + case State::WaitPassword: + case State::WaitRegistration: + return 86400; + case State::WaitCode: + case State::WaitQrCodeConfirmation: + return 5 * 60; + default: + UNREACHABLE(); + return 0; + } + }(); + + if (Timestamp::at(db_state.state_timestamp_.at() + state_timeout).is_in_past()) { LOG(INFO) << "Ignore auth_state: expired " << db_state.state_timestamp_.in(); return false; }