Add td_api::resetPassword.
This commit is contained in:
parent
36e874304f
commit
12383ea1d2
@ -119,7 +119,7 @@ authorizationStateClosed = AuthorizationState;
|
||||
//@description Represents the current state of 2-step verification @has_password True, if a 2-step verification password is set @password_hint Hint for the password; may be empty
|
||||
//@has_recovery_email_address True, if a recovery email is set @has_passport_data True, if some Telegram Passport elements were saved
|
||||
//@recovery_email_address_code_info Information about the recovery email address to which the confirmation email was sent; may be null
|
||||
//@pending_reset_date If not 0, point in time (Unix timestamp) after which password can be reset immediately using resetPassword
|
||||
//@pending_reset_date If not 0, point in time (Unix timestamp) after which the password can be reset immediately using resetPassword
|
||||
passwordState has_password:Bool password_hint:string has_recovery_email_address:Bool has_passport_data:Bool recovery_email_address_code_info:emailAddressAuthenticationCodeInfo pending_reset_date:int32 = PasswordState;
|
||||
|
||||
//@description Contains information about the current recovery email address @recovery_email_address Recovery email address
|
||||
@ -2718,6 +2718,18 @@ checkStickerSetNameResultNameInvalid = CheckStickerSetNameResult;
|
||||
checkStickerSetNameResultNameOccupied = CheckStickerSetNameResult;
|
||||
|
||||
|
||||
//@class ResetPasswordResult @description Represents result of 2-step verification password reset
|
||||
|
||||
//@description The password was reset
|
||||
resetPasswordResultOk = ResetPasswordResult;
|
||||
|
||||
//@description The password reset request is pending @pending_reset_date Point in time (Unix timestamp) after which the password can be reset immediately using resetPassword
|
||||
resetPasswordResultPending pending_reset_date:int32 = ResetPasswordResult;
|
||||
|
||||
//@description The password reset request was declined @retry_date Point in time (Unix timestamp) when the password reset can be retried
|
||||
resetPasswordResultDeclined retry_date:int32 = ResetPasswordResult;
|
||||
|
||||
|
||||
//@class MessageFileType @description Contains information about a file with messages exported from another app
|
||||
|
||||
//@description The messages was exported from a private chat @name Name of the other party; may be empty if unrecognized
|
||||
@ -3923,16 +3935,19 @@ checkRecoveryEmailAddressCode code:string = PasswordState;
|
||||
//@description Resends the 2-step verification recovery email address verification code
|
||||
resendRecoveryEmailAddressCode = PasswordState;
|
||||
|
||||
//@description Requests to send a password recovery code to an email address that was previously set up
|
||||
//@description Requests to send a 2-step verification password recovery code to an email address that was previously set up
|
||||
requestPasswordRecovery = EmailAddressAuthenticationCodeInfo;
|
||||
|
||||
//@description Checks whether a password recovery code sent to an email address is valid @recovery_code Recovery code to check
|
||||
//@description Checks whether a 2-step verification password recovery code sent to an email address is valid @recovery_code Recovery code to check
|
||||
checkPasswordRecoveryCode recovery_code:string = Ok;
|
||||
|
||||
//@description Recovers the password using a recovery code sent to an email address that was previously set up
|
||||
//@description Recovers the 2-step verification password using a recovery code sent to an email address that was previously set up
|
||||
//@recovery_code Recovery code to check @new_password New password of the user; may be empty to remove the password @new_hint New password hint; may be empty
|
||||
recoverPassword recovery_code:string new_password:string new_hint:string = PasswordState;
|
||||
|
||||
//@description Removes 2-step verification password without previous password and access to recovery email address. The password can't be reset immediately and the request needs to be repeated after the specified time
|
||||
resetPassword = ResetPasswordResult;
|
||||
|
||||
//@description Creates a new temporary password for processing payments @password Persistent user password @valid_for Time during which the temporary password will be valid, in seconds; should be between 60 and 86400
|
||||
createTemporaryPassword password:string valid_for:int32 = TemporaryPasswordState;
|
||||
|
||||
|
@ -537,6 +537,33 @@ void PasswordManager::do_recover_password(string code, PasswordInputSettings &&n
|
||||
}));
|
||||
}
|
||||
|
||||
void PasswordManager::reset_password(Promise<ResetPasswordResult> promise) {
|
||||
send_with_promise(
|
||||
G()->net_query_creator().create(telegram_api::account_resetPassword()),
|
||||
PromiseCreator::lambda([promise = std::move(promise)](Result<NetQueryPtr> r_query) mutable {
|
||||
auto r_result = fetch_result<telegram_api::account_resetPassword>(std::move(r_query));
|
||||
if (r_result.is_error()) {
|
||||
return promise.set_error(r_result.move_as_error());
|
||||
}
|
||||
auto result_ptr = r_result.move_as_ok();
|
||||
switch (result_ptr->get_id()) {
|
||||
case telegram_api::account_resetPasswordOk::ID:
|
||||
return promise.set_value(td_api::make_object<td_api::resetPasswordResultOk>());
|
||||
case telegram_api::account_resetPasswordRequestedWait::ID: {
|
||||
auto result = move_tl_object_as<telegram_api::account_resetPasswordRequestedWait>(result_ptr);
|
||||
return promise.set_value(td_api::make_object<td_api::resetPasswordResultPending>(result->until_date_));
|
||||
}
|
||||
case telegram_api::account_resetPasswordFailedWait::ID: {
|
||||
auto result = move_tl_object_as<telegram_api::account_resetPasswordFailedWait>(result_ptr);
|
||||
return promise.set_value(td_api::make_object<td_api::resetPasswordResultDeclined>(result->retry_date_));
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void PasswordManager::update_password_settings(UpdateSettings update_settings, Promise<State> promise) {
|
||||
auto result_promise = PromiseCreator::lambda(
|
||||
[actor_id = actor_id(this), promise = std::move(promise)](Result<bool> r_update_settings) mutable {
|
||||
|
@ -53,6 +53,7 @@ class PasswordManager : public NetQueryCallback {
|
||||
public:
|
||||
using State = tl_object_ptr<td_api::passwordState>;
|
||||
using TempState = tl_object_ptr<td_api::temporaryPasswordState>;
|
||||
using ResetPasswordResult = tl_object_ptr<td_api::ResetPasswordResult>;
|
||||
using PasswordInputSettings = tl_object_ptr<telegram_api::account_passwordInputSettings>;
|
||||
|
||||
explicit PasswordManager(ActorShared<> parent) : parent_(std::move(parent)) {
|
||||
@ -83,6 +84,8 @@ class PasswordManager : public NetQueryCallback {
|
||||
void check_password_recovery_code(string code, Promise<Unit> promise);
|
||||
void recover_password(string code, string new_password, string new_hint, Promise<State> promise);
|
||||
|
||||
void reset_password(Promise<ResetPasswordResult> promise);
|
||||
|
||||
void get_secure_secret(string password, Promise<secure_storage::Secret> promise);
|
||||
void get_input_check_password_srp(string password,
|
||||
Promise<tl_object_ptr<telegram_api::InputCheckPasswordSRP>> &&promise);
|
||||
|
@ -4948,6 +4948,12 @@ void Td::on_request(uint64 id, td_api::recoverPassword &request) {
|
||||
std::move(request.new_password_), std::move(request.new_hint_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::resetPassword &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
send_closure(password_manager_, &PasswordManager::reset_password, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getTemporaryPasswordState &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
|
@ -440,6 +440,8 @@ class Td final : public NetQueryCallback {
|
||||
|
||||
void on_request(uint64 id, td_api::recoverPassword &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::resetPassword &request);
|
||||
|
||||
void on_request(uint64 id, td_api::getTemporaryPasswordState &request);
|
||||
|
||||
void on_request(uint64 id, td_api::createTemporaryPassword &request);
|
||||
|
@ -1781,17 +1781,19 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::checkPhoneNumberVerificationCode>(args));
|
||||
} else if (op == "rpncc") {
|
||||
send_request(td_api::make_object<td_api::resendPhoneNumberVerificationCode>());
|
||||
} else if (op == "rpr" || op == "RequestPasswordRecovery") {
|
||||
} else if (op == "rpr") {
|
||||
send_request(td_api::make_object<td_api::requestPasswordRecovery>());
|
||||
} else if (op == "cprc") {
|
||||
string recovery_code = args;
|
||||
send_request(td_api::make_object<td_api::checkPasswordRecoveryCode>(recovery_code));
|
||||
} else if (op == "rp" || op == "RecoverPassword") {
|
||||
} else if (op == "rp") {
|
||||
string recovery_code;
|
||||
string new_password;
|
||||
string new_hint;
|
||||
get_args(args, recovery_code, new_password, new_hint);
|
||||
send_request(td_api::make_object<td_api::recoverPassword>(recovery_code, new_password, new_hint));
|
||||
} else if (op == "resetp") {
|
||||
send_request(td_api::make_object<td_api::resetPassword>());
|
||||
} else if (op == "gtp" || op == "GetTemporaryPassword") {
|
||||
send_request(td_api::make_object<td_api::getTemporaryPasswordState>());
|
||||
} else if (op == "ctp" || op == "CreateTemporaryPassword") {
|
||||
|
Loading…
Reference in New Issue
Block a user