Allow one day to enter password or register.

GitOrigin-RevId: cc32c0ba6f89a39234e1456739ff8cff09b3649d
This commit is contained in:
levlam 2019-12-20 16:21:55 +03:00
parent 7ed9751b22
commit f9f8b832e3
1 changed files with 15 additions and 1 deletions

View File

@ -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;
}