Support resendRecoveryEmailAddressCode.

GitOrigin-RevId: 598b28a56b44640d2f693b9dc26369931b070b16
This commit is contained in:
levlam 2019-02-10 23:32:49 +03:00
parent de9f167bff
commit eb7268f393
7 changed files with 28 additions and 1 deletions

View File

@ -2598,9 +2598,12 @@ getRecoveryEmailAddress password:string = RecoveryEmailAddress;
//-If new_recovery_email_address is the same as the email address that is currently set up, this call succeeds immediately and aborts all other requests waiting for an email confirmation @password Password of the current user @new_recovery_email_address New recovery email address
setRecoveryEmailAddress password:string new_recovery_email_address:string = PasswordState;
//@description Checks the 2-step verification recovery email address code @code Verification code
//@description Checks the 2-step verification recovery email address verification code @code Verification code
checkRecoveryEmailAddressCode code:string = Ok;
//@description Resends the 2-step verification recovery email address verification code
resendRecoveryEmailAddressCode = Ok;
//@description Requests to send a password recovery code to an email address that was previously set up
requestPasswordRecovery = EmailAddressAuthenticationCodeInfo;

Binary file not shown.

View File

@ -393,6 +393,19 @@ void PasswordManager::check_recovery_email_address_code(string code, Promise<Uni
}));
}
void PasswordManager::resend_recovery_email_address_code(Promise<Unit> promise) {
auto query =
G()->net_query_creator().create(create_storer(telegram_api::account_resendPasswordEmail()));
send_with_promise(std::move(query),
PromiseCreator::lambda([promise = std::move(promise)](Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::account_resendPasswordEmail>(std::move(r_query));
if (r_result.is_error()) {
return promise.set_error(r_result.move_as_error());
}
return promise.set_value(Unit());
}));
}
void PasswordManager::send_email_address_verification_code(
string email, Promise<td_api::object_ptr<td_api::emailAddressAuthenticationCodeInfo>> promise) {
last_verified_email_address_ = email;

View File

@ -67,6 +67,7 @@ class PasswordManager : public NetQueryCallback {
void set_recovery_email_address(string password, string new_recovery_email_address, Promise<State> promise);
void get_recovery_email_address(string password, Promise<tl_object_ptr<td_api::recoveryEmailAddress>> promise);
void check_recovery_email_address_code(string code, Promise<Unit> promise);
void resend_recovery_email_address_code(Promise<Unit> promise);
void send_email_address_verification_code(
string email, Promise<td_api::object_ptr<td_api::emailAddressAuthenticationCodeInfo>> promise);

View File

@ -4658,6 +4658,12 @@ void Td::on_request(uint64 id, td_api::checkRecoveryEmailAddressCode &request) {
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::resendRecoveryEmailAddressCode &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
send_closure(password_manager_, &PasswordManager::resend_recovery_email_address_code, std::move(promise));
}
void Td::on_request(uint64 id, td_api::requestPasswordRecovery &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();

View File

@ -379,6 +379,8 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, td_api::checkRecoveryEmailAddressCode &request);
void on_request(uint64 id, const td_api::resendRecoveryEmailAddressCode &request);
void on_request(uint64 id, td_api::requestPasswordRecovery &request);
void on_request(uint64 id, td_api::recoverPassword &request);

View File

@ -1364,6 +1364,8 @@ class CliClient final : public Actor {
send_request(make_tl_object<td_api::getRecoveryEmailAddress>(args));
} else if (op == "creac") {
send_request(make_tl_object<td_api::checkRecoveryEmailAddressCode>(args));
} else if (op == "rreac") {
send_request(make_tl_object<td_api::resendRecoveryEmailAddressCode>());
} else if (op == "spncc") {
send_request(make_tl_object<td_api::sendPhoneNumberVerificationCode>(args, false, false));
} else if (op == "cpncc") {