Add checkAuthenticationPasswordRecoveryCode.
This commit is contained in:
parent
1394d5d697
commit
709afe3f0c
@ -3870,6 +3870,9 @@ checkAuthenticationPassword password:string = Ok;
|
|||||||
//@description Requests to send a password recovery code to an email address that was previously set up. Works only when the current authorization state is authorizationStateWaitPassword
|
//@description Requests to send a password recovery code to an email address that was previously set up. Works only when the current authorization state is authorizationStateWaitPassword
|
||||||
requestAuthenticationPasswordRecovery = Ok;
|
requestAuthenticationPasswordRecovery = Ok;
|
||||||
|
|
||||||
|
//@description Checks whether a password recovery code sent to an email address is valid. Works only when the current authorization state is authorizationStateWaitPassword @recovery_code Recovery code to check
|
||||||
|
checkAuthenticationPasswordRecoveryCode recovery_code:string = Ok;
|
||||||
|
|
||||||
//@description Recovers the password with a password recovery code sent to an email address that was previously set up. Works only when the current authorization state is authorizationStateWaitPassword
|
//@description Recovers the password with a password recovery code sent to an email address that was previously set up. Works only when the current authorization state is authorizationStateWaitPassword
|
||||||
//@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
|
//@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
|
||||||
recoverAuthenticationPassword recovery_code:string new_password:string new_hint:string = Ok;
|
recoverAuthenticationPassword recovery_code:string new_password:string new_hint:string = Ok;
|
||||||
|
@ -329,13 +329,20 @@ void AuthManager::request_password_recovery(uint64 query_id) {
|
|||||||
G()->net_query_creator().create_unauth(telegram_api::auth_requestPasswordRecovery()));
|
G()->net_query_creator().create_unauth(telegram_api::auth_requestPasswordRecovery()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AuthManager::check_password_recovery_code(uint64 query_id, string code) {
|
||||||
|
if (state_ != State::WaitPassword) {
|
||||||
|
return on_query_error(query_id, Status::Error(8, "Call to checkAuthenticationPasswordRecoveryCode unexpected"));
|
||||||
|
}
|
||||||
|
|
||||||
|
on_new_query(query_id);
|
||||||
|
start_net_query(NetQueryType::CheckPasswordRecoveryCode,
|
||||||
|
G()->net_query_creator().create_unauth(telegram_api::auth_checkRecoveryPassword(code)));
|
||||||
|
}
|
||||||
|
|
||||||
void AuthManager::recover_password(uint64 query_id, string code, string new_password, string new_hint) {
|
void AuthManager::recover_password(uint64 query_id, string code, string new_password, string new_hint) {
|
||||||
if (state_ != State::WaitPassword) {
|
if (state_ != State::WaitPassword) {
|
||||||
return on_query_error(query_id, Status::Error(8, "Call to recoverAuthenticationPassword unexpected"));
|
return on_query_error(query_id, Status::Error(8, "Call to recoverAuthenticationPassword unexpected"));
|
||||||
}
|
}
|
||||||
if (code.empty()) {
|
|
||||||
return on_query_error(query_id, Status::Error(8, "Recovery code can't be empty"));
|
|
||||||
}
|
|
||||||
|
|
||||||
on_new_query(query_id);
|
on_new_query(query_id);
|
||||||
if (!new_password.empty()) {
|
if (!new_password.empty()) {
|
||||||
@ -635,6 +642,17 @@ void AuthManager::on_request_password_recovery_result(NetQueryPtr &result) {
|
|||||||
on_query_ok();
|
on_query_ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AuthManager::on_check_password_recovery_code_result(NetQueryPtr &result) {
|
||||||
|
auto r_success = fetch_result<telegram_api::auth_checkRecoveryPassword>(result->ok());
|
||||||
|
if (r_success.is_error()) {
|
||||||
|
return on_query_error(r_success.move_as_error());
|
||||||
|
}
|
||||||
|
if (!r_success.ok()) {
|
||||||
|
return on_query_error(Status::Error(400, "Invalid recovery code"));
|
||||||
|
}
|
||||||
|
on_query_ok();
|
||||||
|
}
|
||||||
|
|
||||||
void AuthManager::on_authentication_result(NetQueryPtr &result, bool is_from_current_query) {
|
void AuthManager::on_authentication_result(NetQueryPtr &result, bool is_from_current_query) {
|
||||||
auto r_sign_in = fetch_result<telegram_api::auth_signIn>(result->ok());
|
auto r_sign_in = fetch_result<telegram_api::auth_signIn>(result->ok());
|
||||||
if (r_sign_in.is_error()) {
|
if (r_sign_in.is_error()) {
|
||||||
@ -858,6 +876,9 @@ void AuthManager::on_result(NetQueryPtr result) {
|
|||||||
case NetQueryType::RequestPasswordRecovery:
|
case NetQueryType::RequestPasswordRecovery:
|
||||||
on_request_password_recovery_result(result);
|
on_request_password_recovery_result(result);
|
||||||
break;
|
break;
|
||||||
|
case NetQueryType::CheckPasswordRecoveryCode:
|
||||||
|
on_check_password_recovery_code_result(result);
|
||||||
|
break;
|
||||||
case NetQueryType::LogOut:
|
case NetQueryType::LogOut:
|
||||||
on_log_out_result(result);
|
on_log_out_result(result);
|
||||||
break;
|
break;
|
||||||
|
@ -42,6 +42,7 @@ class AuthManager : public NetActor {
|
|||||||
void check_bot_token(uint64 query_id, string bot_token);
|
void check_bot_token(uint64 query_id, string bot_token);
|
||||||
void check_password(uint64 query_id, string password);
|
void check_password(uint64 query_id, string password);
|
||||||
void request_password_recovery(uint64 query_id);
|
void request_password_recovery(uint64 query_id);
|
||||||
|
void check_password_recovery_code(uint64 query_id, string code);
|
||||||
void recover_password(uint64 query_id, string code, string new_password, string new_hint);
|
void recover_password(uint64 query_id, string code, string new_password, string new_hint);
|
||||||
void log_out(uint64 query_id);
|
void log_out(uint64 query_id);
|
||||||
void delete_account(uint64 query_id, const string &reason);
|
void delete_account(uint64 query_id, const string &reason);
|
||||||
@ -79,6 +80,7 @@ class AuthManager : public NetActor {
|
|||||||
GetPassword,
|
GetPassword,
|
||||||
CheckPassword,
|
CheckPassword,
|
||||||
RequestPasswordRecovery,
|
RequestPasswordRecovery,
|
||||||
|
CheckPasswordRecoveryCode,
|
||||||
RecoverPassword,
|
RecoverPassword,
|
||||||
BotAuthentication,
|
BotAuthentication,
|
||||||
Authentication,
|
Authentication,
|
||||||
@ -229,6 +231,7 @@ class AuthManager : public NetActor {
|
|||||||
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);
|
||||||
|
void on_check_password_recovery_code_result(NetQueryPtr &result);
|
||||||
void on_authentication_result(NetQueryPtr &result, bool expected_flag);
|
void on_authentication_result(NetQueryPtr &result, bool expected_flag);
|
||||||
void on_log_out_result(NetQueryPtr &result);
|
void on_log_out_result(NetQueryPtr &result);
|
||||||
void on_delete_account_result(NetQueryPtr &result);
|
void on_delete_account_result(NetQueryPtr &result);
|
||||||
|
@ -3219,6 +3219,7 @@ bool Td::is_authentication_request(int32 id) {
|
|||||||
case td_api::requestQrCodeAuthentication::ID:
|
case td_api::requestQrCodeAuthentication::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::recoverAuthenticationPassword::ID:
|
case td_api::recoverAuthenticationPassword::ID:
|
||||||
case td_api::deleteAccount::ID:
|
case td_api::deleteAccount::ID:
|
||||||
case td_api::logOut::ID:
|
case td_api::logOut::ID:
|
||||||
@ -4781,8 +4782,15 @@ void Td::on_request(uint64 id, const td_api::requestAuthenticationPasswordRecove
|
|||||||
send_closure(auth_manager_actor_, &AuthManager::request_password_recovery, id);
|
send_closure(auth_manager_actor_, &AuthManager::request_password_recovery, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, td_api::checkAuthenticationPasswordRecoveryCode &request) {
|
||||||
|
CLEAN_INPUT_STRING(request.recovery_code_);
|
||||||
|
send_closure(auth_manager_actor_, &AuthManager::check_password_recovery_code, id, std::move(request.recovery_code_));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::recoverAuthenticationPassword &request) {
|
void Td::on_request(uint64 id, td_api::recoverAuthenticationPassword &request) {
|
||||||
CLEAN_INPUT_STRING(request.recovery_code_);
|
CLEAN_INPUT_STRING(request.recovery_code_);
|
||||||
|
CLEAN_INPUT_STRING(request.new_password_);
|
||||||
|
CLEAN_INPUT_STRING(request.new_hint_);
|
||||||
send_closure(auth_manager_actor_, &AuthManager::recover_password, id, std::move(request.recovery_code_),
|
send_closure(auth_manager_actor_, &AuthManager::recover_password, id, std::move(request.recovery_code_),
|
||||||
std::move(request.new_password_), std::move(request.new_hint_));
|
std::move(request.new_password_), std::move(request.new_hint_));
|
||||||
}
|
}
|
||||||
@ -4925,6 +4933,8 @@ void Td::on_request(uint64 id, td_api::requestPasswordRecovery &request) {
|
|||||||
void Td::on_request(uint64 id, td_api::recoverPassword &request) {
|
void Td::on_request(uint64 id, td_api::recoverPassword &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CLEAN_INPUT_STRING(request.recovery_code_);
|
CLEAN_INPUT_STRING(request.recovery_code_);
|
||||||
|
CLEAN_INPUT_STRING(request.new_password_);
|
||||||
|
CLEAN_INPUT_STRING(request.new_hint_);
|
||||||
CREATE_REQUEST_PROMISE();
|
CREATE_REQUEST_PROMISE();
|
||||||
send_closure(password_manager_, &PasswordManager::recover_password, std::move(request.recovery_code_),
|
send_closure(password_manager_, &PasswordManager::recover_password, std::move(request.recovery_code_),
|
||||||
std::move(request.new_password_), std::move(request.new_hint_), std::move(promise));
|
std::move(request.new_password_), std::move(request.new_hint_), std::move(promise));
|
||||||
|
@ -406,6 +406,8 @@ class Td final : public NetQueryCallback {
|
|||||||
|
|
||||||
void on_request(uint64 id, const td_api::requestAuthenticationPasswordRecovery &request);
|
void on_request(uint64 id, const td_api::requestAuthenticationPasswordRecovery &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, td_api::checkAuthenticationPasswordRecoveryCode &request);
|
||||||
|
|
||||||
void on_request(uint64 id, td_api::recoverAuthenticationPassword &request);
|
void on_request(uint64 id, td_api::recoverAuthenticationPassword &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::logOut &request);
|
void on_request(uint64 id, const td_api::logOut &request);
|
||||||
|
@ -1654,6 +1654,9 @@ class CliClient final : public Actor {
|
|||||||
send_request(td_api::make_object<td_api::getCurrentState>());
|
send_request(td_api::make_object<td_api::getCurrentState>());
|
||||||
} 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") {
|
||||||
|
string code = args;
|
||||||
|
send_request(td_api::make_object<td_api::checkAuthenticationPasswordRecoveryCode>(code));
|
||||||
} else if (op == "rap") {
|
} else if (op == "rap") {
|
||||||
string code;
|
string code;
|
||||||
string new_password;
|
string new_password;
|
||||||
|
Loading…
Reference in New Issue
Block a user