Add td_api::resetAuthenticationEmailAddress.
This commit is contained in:
parent
e47adeab37
commit
1af942de49
@ -5754,6 +5754,10 @@ requestQrCodeAuthentication other_user_ids:vector<int53> = Ok;
|
|||||||
//@last_name The last name of the user; 0-64 characters
|
//@last_name The last name of the user; 0-64 characters
|
||||||
registerUser first_name:string last_name:string = Ok;
|
registerUser first_name:string last_name:string = Ok;
|
||||||
|
|
||||||
|
//@description Resets the login email address. May return an error with a message "TASK_ALREADY_EXISTS" if reset is still pending.
|
||||||
|
//-Works only when the current authorization state is authorizationStateWaitEmailCode and authorization_state.can_reset_email_address == true
|
||||||
|
resetAuthenticationEmailAddress = Ok;
|
||||||
|
|
||||||
//@description Checks the 2-step verification password for correctness. Works only when the current authorization state is authorizationStateWaitPassword @password The 2-step verification password to check
|
//@description Checks the 2-step verification password for correctness. Works only when the current authorization state is authorizationStateWaitPassword @password The 2-step verification password to check
|
||||||
checkAuthenticationPassword password:string = Ok;
|
checkAuthenticationPassword password:string = Ok;
|
||||||
|
|
||||||
|
@ -378,6 +378,17 @@ void AuthManager::check_email_code(uint64 query_id, EmailVerification &&code) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AuthManager::reset_email_address(uint64 query_id) {
|
||||||
|
if (state_ != State::WaitEmailCode) {
|
||||||
|
return on_query_error(query_id, Status::Error(400, "Call to resetAuthenticationEmailAddress unexpected"));
|
||||||
|
}
|
||||||
|
|
||||||
|
on_new_query(query_id);
|
||||||
|
start_net_query(NetQueryType::ResetEmailAddress,
|
||||||
|
G()->net_query_creator().create_unauth(telegram_api::auth_resetLoginEmail(
|
||||||
|
send_code_helper_.phone_number().str(), send_code_helper_.phone_code_hash().str())));
|
||||||
|
}
|
||||||
|
|
||||||
void AuthManager::check_code(uint64 query_id, string code) {
|
void AuthManager::check_code(uint64 query_id, string code) {
|
||||||
if (state_ != State::WaitCode) {
|
if (state_ != State::WaitCode) {
|
||||||
return on_query_error(query_id, Status::Error(400, "Call to checkAuthenticationCode unexpected"));
|
return on_query_error(query_id, Status::Error(400, "Call to checkAuthenticationCode unexpected"));
|
||||||
@ -580,6 +591,7 @@ void AuthManager::start_net_query(NetQueryType net_query_type, NetQueryPtr net_q
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AuthManager::on_sent_code(telegram_api::object_ptr<telegram_api::auth_SentCode> &&sent_code_ptr) {
|
void AuthManager::on_sent_code(telegram_api::object_ptr<telegram_api::auth_SentCode> &&sent_code_ptr) {
|
||||||
|
LOG(INFO) << "Receive " << to_string(sent_code_ptr);
|
||||||
auto sent_code_id = sent_code_ptr->get_id();
|
auto sent_code_id = sent_code_ptr->get_id();
|
||||||
if (sent_code_id != telegram_api::auth_sentCode::ID) {
|
if (sent_code_id != telegram_api::auth_sentCode::ID) {
|
||||||
CHECK(sent_code_id == telegram_api::auth_sentCodeSuccess::ID);
|
CHECK(sent_code_id == telegram_api::auth_sentCodeSuccess::ID);
|
||||||
@ -600,7 +612,9 @@ void AuthManager::on_sent_code(telegram_api::object_ptr<telegram_api::auth_SentC
|
|||||||
allow_apple_id_ = code_type->apple_signin_allowed_;
|
allow_apple_id_ = code_type->apple_signin_allowed_;
|
||||||
allow_google_id_ = code_type->google_signin_allowed_;
|
allow_google_id_ = code_type->google_signin_allowed_;
|
||||||
email_address_.clear();
|
email_address_.clear();
|
||||||
email_code_info_ = SentEmailCode(std::move(code_type->email_pattern_), code_type->length_);
|
if (!code_type->email_pattern_.empty() || email_code_info_.is_empty()) {
|
||||||
|
email_code_info_ = SentEmailCode(std::move(code_type->email_pattern_), code_type->length_);
|
||||||
|
}
|
||||||
reset_available_period_ = -1;
|
reset_available_period_ = -1;
|
||||||
reset_pending_date_ = -1;
|
reset_pending_date_ = -1;
|
||||||
if (code_type->reset_pending_date_ > 0) {
|
if (code_type->reset_pending_date_ > 0) {
|
||||||
@ -625,10 +639,7 @@ void AuthManager::on_send_code_result(NetQueryPtr &result) {
|
|||||||
if (r_sent_code.is_error()) {
|
if (r_sent_code.is_error()) {
|
||||||
return on_query_error(r_sent_code.move_as_error());
|
return on_query_error(r_sent_code.move_as_error());
|
||||||
}
|
}
|
||||||
auto sent_code = r_sent_code.move_as_ok();
|
on_sent_code(r_sent_code.move_as_ok());
|
||||||
|
|
||||||
LOG(INFO) << "Receive " << to_string(sent_code);
|
|
||||||
on_sent_code(std::move(sent_code));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuthManager::on_send_email_code_result(NetQueryPtr &result) {
|
void AuthManager::on_send_email_code_result(NetQueryPtr &result) {
|
||||||
@ -667,6 +678,20 @@ void AuthManager::on_verify_email_address_result(NetQueryPtr &result) {
|
|||||||
on_sent_code(std::move(verified_login->sent_code_));
|
on_sent_code(std::move(verified_login->sent_code_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AuthManager::on_reset_email_address_result(NetQueryPtr &result) {
|
||||||
|
auto r_sent_code = fetch_result<telegram_api::auth_resetLoginEmail>(result->ok());
|
||||||
|
if (r_sent_code.is_error()) {
|
||||||
|
if (reset_available_period_ > 0 && reset_pending_date_ == -1 &&
|
||||||
|
r_sent_code.error().message() == "TASK_ALREADY_EXISTS") {
|
||||||
|
reset_pending_date_ = G()->unix_time() + reset_available_period_;
|
||||||
|
reset_available_period_ = -1;
|
||||||
|
update_state(State::WaitEmailCode, true);
|
||||||
|
}
|
||||||
|
return on_query_error(r_sent_code.move_as_error());
|
||||||
|
}
|
||||||
|
on_sent_code(r_sent_code.move_as_ok());
|
||||||
|
}
|
||||||
|
|
||||||
void AuthManager::on_request_qr_code_result(NetQueryPtr &result, bool is_import) {
|
void AuthManager::on_request_qr_code_result(NetQueryPtr &result, bool is_import) {
|
||||||
Status status;
|
Status status;
|
||||||
if (result->is_ok()) {
|
if (result->is_ok()) {
|
||||||
@ -1105,6 +1130,9 @@ void AuthManager::on_result(NetQueryPtr result) {
|
|||||||
case NetQueryType::VerifyEmailAddress:
|
case NetQueryType::VerifyEmailAddress:
|
||||||
on_verify_email_address_result(result);
|
on_verify_email_address_result(result);
|
||||||
break;
|
break;
|
||||||
|
case NetQueryType::ResetEmailAddress:
|
||||||
|
on_reset_email_address_result(result);
|
||||||
|
break;
|
||||||
case NetQueryType::RequestQrCode:
|
case NetQueryType::RequestQrCode:
|
||||||
on_request_qr_code_result(result, false);
|
on_request_qr_code_result(result, false);
|
||||||
break;
|
break;
|
||||||
|
@ -41,6 +41,7 @@ class AuthManager final : public NetActor {
|
|||||||
void set_email_address(uint64 query_id, string email_address);
|
void set_email_address(uint64 query_id, string email_address);
|
||||||
void resend_authentication_code(uint64 query_id);
|
void resend_authentication_code(uint64 query_id);
|
||||||
void check_email_code(uint64 query_id, EmailVerification &&code);
|
void check_email_code(uint64 query_id, EmailVerification &&code);
|
||||||
|
void reset_email_address(uint64 query_id);
|
||||||
void check_code(uint64 query_id, string code);
|
void check_code(uint64 query_id, string code);
|
||||||
void register_user(uint64 query_id, string first_name, string last_name);
|
void register_user(uint64 query_id, string first_name, string last_name);
|
||||||
void request_qr_code_authentication(uint64 query_id, vector<UserId> other_user_ids);
|
void request_qr_code_authentication(uint64 query_id, vector<UserId> other_user_ids);
|
||||||
@ -84,6 +85,7 @@ class AuthManager final : public NetActor {
|
|||||||
SendCode,
|
SendCode,
|
||||||
SendEmailCode,
|
SendEmailCode,
|
||||||
VerifyEmailAddress,
|
VerifyEmailAddress,
|
||||||
|
ResetEmailAddress,
|
||||||
RequestQrCode,
|
RequestQrCode,
|
||||||
ImportQrCode,
|
ImportQrCode,
|
||||||
GetPassword,
|
GetPassword,
|
||||||
@ -308,6 +310,7 @@ class AuthManager final : public NetActor {
|
|||||||
void on_send_code_result(NetQueryPtr &result);
|
void on_send_code_result(NetQueryPtr &result);
|
||||||
void on_send_email_code_result(NetQueryPtr &result);
|
void on_send_email_code_result(NetQueryPtr &result);
|
||||||
void on_verify_email_address_result(NetQueryPtr &result);
|
void on_verify_email_address_result(NetQueryPtr &result);
|
||||||
|
void on_reset_email_address_result(NetQueryPtr &result);
|
||||||
void on_request_qr_code_result(NetQueryPtr &result, bool is_import);
|
void on_request_qr_code_result(NetQueryPtr &result, bool is_import);
|
||||||
void on_get_password_result(NetQueryPtr &result);
|
void on_get_password_result(NetQueryPtr &result);
|
||||||
void on_request_password_recovery_result(NetQueryPtr &result);
|
void on_request_password_recovery_result(NetQueryPtr &result);
|
||||||
|
@ -2732,6 +2732,7 @@ bool Td::is_authentication_request(int32 id) {
|
|||||||
case td_api::checkAuthenticationCode::ID:
|
case td_api::checkAuthenticationCode::ID:
|
||||||
case td_api::registerUser::ID:
|
case td_api::registerUser::ID:
|
||||||
case td_api::requestQrCodeAuthentication::ID:
|
case td_api::requestQrCodeAuthentication::ID:
|
||||||
|
case td_api::resetAuthenticationEmailAddress::ID:
|
||||||
case td_api::checkAuthenticationPassword::ID:
|
case td_api::checkAuthenticationPassword::ID:
|
||||||
case td_api::requestAuthenticationPasswordRecovery::ID:
|
case td_api::requestAuthenticationPasswordRecovery::ID:
|
||||||
case td_api::checkAuthenticationPasswordRecoveryCode::ID:
|
case td_api::checkAuthenticationPasswordRecoveryCode::ID:
|
||||||
@ -4168,6 +4169,10 @@ void Td::on_request(uint64 id, td_api::requestQrCodeAuthentication &request) {
|
|||||||
UserId::get_user_ids(request.other_user_ids_));
|
UserId::get_user_ids(request.other_user_ids_));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::resetAuthenticationEmailAddress &request) {
|
||||||
|
send_closure(auth_manager_actor_, &AuthManager::reset_email_address, id);
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::checkAuthenticationPassword &request) {
|
void Td::on_request(uint64 id, td_api::checkAuthenticationPassword &request) {
|
||||||
CLEAN_INPUT_STRING(request.password_);
|
CLEAN_INPUT_STRING(request.password_);
|
||||||
send_closure(auth_manager_actor_, &AuthManager::check_password, id, std::move(request.password_));
|
send_closure(auth_manager_actor_, &AuthManager::check_password, id, std::move(request.password_));
|
||||||
|
@ -421,6 +421,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, td_api::requestQrCodeAuthentication &request);
|
void on_request(uint64 id, td_api::requestQrCodeAuthentication &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::resetAuthenticationEmailAddress &request);
|
||||||
|
|
||||||
void on_request(uint64 id, td_api::checkAuthenticationPassword &request);
|
void on_request(uint64 id, td_api::checkAuthenticationPassword &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::requestAuthenticationPasswordRecovery &request);
|
void on_request(uint64 id, const td_api::requestAuthenticationPasswordRecovery &request);
|
||||||
|
@ -1922,6 +1922,8 @@ class CliClient final : public Actor {
|
|||||||
send_request(td_api::make_object<td_api::confirmQrCodeAuthentication>(args));
|
send_request(td_api::make_object<td_api::confirmQrCodeAuthentication>(args));
|
||||||
} else if (op == "gcs") {
|
} else if (op == "gcs") {
|
||||||
send_request(td_api::make_object<td_api::getCurrentState>());
|
send_request(td_api::make_object<td_api::getCurrentState>());
|
||||||
|
} else if (op == "raea") {
|
||||||
|
send_request(td_api::make_object<td_api::resetAuthenticationEmailAddress>());
|
||||||
} else if (op == "rapr") {
|
} else if (op == "rapr") {
|
||||||
send_request(td_api::make_object<td_api::requestAuthenticationPasswordRecovery>());
|
send_request(td_api::make_object<td_api::requestAuthenticationPasswordRecovery>());
|
||||||
} else if (op == "caprc") {
|
} else if (op == "caprc") {
|
||||||
|
Loading…
Reference in New Issue
Block a user