From f9f8b832e38601411a77899ed2c4da9ad7e06180 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 20 Dec 2019 16:21:55 +0300 Subject: [PATCH] Allow one day to enter password or register. GitOrigin-RevId: cc32c0ba6f89a39234e1456739ff8cff09b3649d --- td/telegram/AuthManager.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/td/telegram/AuthManager.cpp b/td/telegram/AuthManager.cpp index bd23636c7..d23dec7b1 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; }