Add authorizationStateWaitEmailCode.next_phone_number_authorization_date.
This commit is contained in:
parent
cba73d5bba
commit
8f16191182
@ -109,8 +109,10 @@ authorizationStateWaitPhoneNumber = AuthorizationState;
|
||||
authorizationStateWaitEmailAddress allow_apple_id:Bool allow_google_id:Bool = AuthorizationState;
|
||||
|
||||
//@description TDLib needs the user's authentication code sent to an email address to authorize. Call `checkAuthenticationEmailCode` to provide the code
|
||||
//@allow_apple_id True, if authorization through Apple ID is allowed @allow_google_id True, if authorization through Google ID is allowed @code_info Information about the sent authentication code
|
||||
authorizationStateWaitEmailCode allow_apple_id:Bool allow_google_id:Bool code_info:emailAddressAuthenticationCodeInfo = AuthorizationState;
|
||||
//@allow_apple_id True, if authorization through Apple ID is allowed @allow_google_id True, if authorization through Google ID is allowed
|
||||
//@code_info Information about the sent authentication code
|
||||
//@next_phone_number_authorization_date Point in time (Unix timestamp) when the user will be able to authorize with a code sent to the user's phone number; 0 if unknown
|
||||
authorizationStateWaitEmailCode allow_apple_id:Bool allow_google_id:Bool code_info:emailAddressAuthenticationCodeInfo next_phone_number_authorization_date:int32 = AuthorizationState;
|
||||
|
||||
//@description TDLib needs the user's authentication code to authorize @code_info Information about the authorization code that was sent
|
||||
authorizationStateWaitCode code_info:authenticationCodeInfo = AuthorizationState;
|
||||
|
@ -111,7 +111,8 @@ tl_object_ptr<td_api::AuthorizationState> AuthManager::get_authorization_state_o
|
||||
return make_tl_object<td_api::authorizationStateWaitEmailAddress>(allow_apple_id_, allow_google_id_);
|
||||
case State::WaitEmailCode:
|
||||
return make_tl_object<td_api::authorizationStateWaitEmailCode>(
|
||||
allow_apple_id_, allow_google_id_, email_code_info_.get_email_address_authentication_code_info_object());
|
||||
allow_apple_id_, allow_google_id_, email_code_info_.get_email_address_authentication_code_info_object(),
|
||||
next_phone_number_login_date_);
|
||||
case State::WaitCode:
|
||||
return send_code_helper_.get_authorization_state_wait_code();
|
||||
case State::WaitQrCodeConfirmation:
|
||||
@ -268,6 +269,7 @@ void AuthManager::set_phone_number(uint64 query_id, string phone_number,
|
||||
allow_google_id_ = false;
|
||||
email_address_ = {};
|
||||
email_code_info_ = {};
|
||||
next_phone_number_login_date_ = 0;
|
||||
code_ = string();
|
||||
email_code_ = nullptr;
|
||||
|
||||
@ -562,6 +564,7 @@ void AuthManager::on_sent_code(telegram_api::object_ptr<telegram_api::auth_sentC
|
||||
allow_google_id_ = code_type->google_signin_allowed_;
|
||||
email_address_.clear();
|
||||
email_code_info_ = SentEmailCode(std::move(code_type->email_pattern_), code_type->length_);
|
||||
next_phone_number_login_date_ = td::max(static_cast<int32>(0), code_type->next_phone_login_date_);
|
||||
if (email_code_info_.is_empty()) {
|
||||
email_code_info_ = SentEmailCode("<unknown>", code_type->length_);
|
||||
CHECK(!email_code_info_.is_empty());
|
||||
@ -598,6 +601,7 @@ void AuthManager::on_send_email_code_result(NetQueryPtr &result) {
|
||||
if (email_code_info_.is_empty()) {
|
||||
return on_query_error(Status::Error(500, "Receive invalid response"));
|
||||
}
|
||||
next_phone_number_login_date_ = 0;
|
||||
|
||||
update_state(State::WaitEmailCode, true);
|
||||
on_query_ok();
|
||||
@ -1146,6 +1150,7 @@ bool AuthManager::load_state() {
|
||||
allow_google_id_ = db_state.allow_google_id_;
|
||||
email_address_ = std::move(db_state.email_address_);
|
||||
email_code_info_ = std::move(db_state.email_code_info_);
|
||||
next_phone_number_login_date_ = db_state.next_phone_number_login_date_;
|
||||
send_code_helper_ = std::move(db_state.send_code_helper_);
|
||||
} else if (db_state.state_ == State::WaitCode) {
|
||||
send_code_helper_ = std::move(db_state.send_code_helper_);
|
||||
@ -1179,7 +1184,7 @@ void AuthManager::save_state() {
|
||||
return DbState::wait_email_address(api_id_, api_hash_, allow_apple_id_, allow_google_id_, send_code_helper_);
|
||||
} else if (state_ == State::WaitEmailCode) {
|
||||
return DbState::wait_email_code(api_id_, api_hash_, allow_apple_id_, allow_google_id_, email_address_,
|
||||
email_code_info_, send_code_helper_);
|
||||
email_code_info_, next_phone_number_login_date_, send_code_helper_);
|
||||
} else if (state_ == State::WaitCode) {
|
||||
return DbState::wait_code(api_id_, api_hash_, send_code_helper_);
|
||||
} else if (state_ == State::WaitQrCodeConfirmation) {
|
||||
|
@ -125,6 +125,7 @@ class AuthManager final : public NetActor {
|
||||
// WaitEmailCode
|
||||
string email_address_;
|
||||
SentEmailCode email_code_info_;
|
||||
int32 next_phone_number_login_date_ = 0;
|
||||
|
||||
// WaitEmailAddress, WaitEmailCode, WaitCode and WaitRegistration
|
||||
SendCodeHelper send_code_helper_;
|
||||
@ -153,13 +154,14 @@ class AuthManager final : public NetActor {
|
||||
|
||||
static DbState wait_email_code(int32 api_id, string api_hash, bool allow_apple_id, bool allow_google_id,
|
||||
string email_address, SentEmailCode email_code_info,
|
||||
SendCodeHelper send_code_helper) {
|
||||
int32 next_phone_number_login_date, SendCodeHelper send_code_helper) {
|
||||
DbState state(State::WaitEmailCode, api_id, std::move(api_hash));
|
||||
state.send_code_helper_ = std::move(send_code_helper);
|
||||
state.allow_apple_id_ = allow_apple_id;
|
||||
state.allow_google_id_ = allow_google_id;
|
||||
state.email_address_ = std::move(email_address);
|
||||
state.email_code_info_ = std::move(email_code_info);
|
||||
state.next_phone_number_login_date_ = next_phone_number_login_date;
|
||||
return state;
|
||||
}
|
||||
|
||||
@ -220,6 +222,7 @@ class AuthManager final : public NetActor {
|
||||
// State::WaitEmailCode
|
||||
string email_address_;
|
||||
SentEmailCode email_code_info_;
|
||||
int32 next_phone_number_login_date_ = 0;
|
||||
td_api::object_ptr<td_api::EmailAddressAuthentication> email_code_;
|
||||
|
||||
// State::WaitCode
|
||||
|
@ -80,6 +80,7 @@ void AuthManager::DbState::store(StorerT &storer) const {
|
||||
store(send_code_helper_, storer);
|
||||
store(email_address_, storer);
|
||||
store(email_code_info_, storer);
|
||||
store(next_phone_number_login_date_, storer);
|
||||
} else if (state_ == State::WaitCode) {
|
||||
store(send_code_helper_, storer);
|
||||
} else if (state_ == State::WaitQrCodeConfirmation) {
|
||||
@ -139,6 +140,7 @@ void AuthManager::DbState::parse(ParserT &parser) {
|
||||
parse(send_code_helper_, parser);
|
||||
parse(email_address_, parser);
|
||||
parse(email_code_info_, parser);
|
||||
parse(next_phone_number_login_date_, parser);
|
||||
} else if (state_ == State::WaitCode) {
|
||||
parse(send_code_helper_, parser);
|
||||
} else if (state_ == State::WaitQrCodeConfirmation) {
|
||||
|
Loading…
Reference in New Issue
Block a user