Add sendAuthenticationFirebaseSms.
This commit is contained in:
parent
f596ec7793
commit
65ddaea0f6
@ -5581,6 +5581,10 @@ checkAuthenticationPasswordRecoveryCode recovery_code:string = Ok;
|
||||
//@new_hint New password hint; may be empty
|
||||
recoverAuthenticationPassword recovery_code:string new_password:string new_hint:string = Ok;
|
||||
|
||||
//@description Sends Firebase Authentication SMS to the phone number of the user. Works only when the current authorization state is authorizationStateWaitCode and the server returned code of the type authenticationCodeTypeFirebaseAndroid or authenticationCodeTypeFirebaseIos
|
||||
//@token SafetyNet Attestation API token for the Android application, or secret from push notification for the iOS application
|
||||
sendAuthenticationFirebaseSms token:string = Ok;
|
||||
|
||||
//@description Checks the authentication token of a bot; to log in as a bot. Works only when the current authorization state is authorizationStateWaitPhoneNumber. Can be used instead of setAuthenticationPhoneNumber and checkAuthenticationCode to log in @token The bot token
|
||||
checkAuthenticationBotToken token:string = Ok;
|
||||
|
||||
|
@ -284,6 +284,16 @@ void AuthManager::set_phone_number(uint64 query_id, string phone_number,
|
||||
std::move(phone_number), settings, api_id_, api_hash_)));
|
||||
}
|
||||
|
||||
void AuthManager::set_firebase_token(uint64 query_id, string token) {
|
||||
if (state_ != State::WaitCode) {
|
||||
return on_query_error(query_id, Status::Error(400, "Call to sendAuthenticationFirebaseSms unexpected"));
|
||||
}
|
||||
on_new_query(query_id);
|
||||
|
||||
start_net_query(NetQueryType::RequestFirebaseSms,
|
||||
G()->net_query_creator().create_unauth(send_code_helper_.request_firebase_sms(token)));
|
||||
}
|
||||
|
||||
void AuthManager::set_email_address(uint64 query_id, string email_address) {
|
||||
if (state_ != State::WaitEmailAddress) {
|
||||
if (state_ == State::WaitEmailCode && net_query_id_ == 0) {
|
||||
@ -824,6 +834,14 @@ void AuthManager::on_check_password_recovery_code_result(NetQueryPtr &result) {
|
||||
on_query_ok();
|
||||
}
|
||||
|
||||
void AuthManager::on_request_firebase_sms_result(NetQueryPtr &result) {
|
||||
auto r_bool = fetch_result<telegram_api::auth_requestFirebaseSms>(result->ok());
|
||||
if (r_bool.is_error()) {
|
||||
return on_query_error(r_bool.move_as_error());
|
||||
}
|
||||
on_query_ok();
|
||||
}
|
||||
|
||||
void AuthManager::on_authentication_result(NetQueryPtr &result, bool is_from_current_query) {
|
||||
auto r_sign_in = fetch_result<telegram_api::auth_signIn>(result->ok());
|
||||
if (r_sign_in.is_error()) {
|
||||
@ -1080,6 +1098,9 @@ void AuthManager::on_result(NetQueryPtr result) {
|
||||
case NetQueryType::CheckPasswordRecoveryCode:
|
||||
on_check_password_recovery_code_result(result);
|
||||
break;
|
||||
case NetQueryType::RequestFirebaseSms:
|
||||
on_request_firebase_sms_result(result);
|
||||
break;
|
||||
case NetQueryType::LogOut:
|
||||
on_log_out_result(result);
|
||||
break;
|
||||
|
@ -37,6 +37,7 @@ class AuthManager final : public NetActor {
|
||||
|
||||
void set_phone_number(uint64 query_id, string phone_number,
|
||||
td_api::object_ptr<td_api::phoneNumberAuthenticationSettings> settings);
|
||||
void set_firebase_token(uint64 query_id, string token);
|
||||
void set_email_address(uint64 query_id, string email_address);
|
||||
void resend_authentication_code(uint64 query_id);
|
||||
void check_email_code(uint64 query_id, EmailVerification &&code);
|
||||
@ -90,6 +91,7 @@ class AuthManager final : public NetActor {
|
||||
RequestPasswordRecovery,
|
||||
CheckPasswordRecoveryCode,
|
||||
RecoverPassword,
|
||||
RequestFirebaseSms,
|
||||
BotAuthentication,
|
||||
Authentication,
|
||||
LogOut,
|
||||
@ -305,6 +307,7 @@ class AuthManager final : public NetActor {
|
||||
void on_get_password_result(NetQueryPtr &result);
|
||||
void on_request_password_recovery_result(NetQueryPtr &result);
|
||||
void on_check_password_recovery_code_result(NetQueryPtr &result);
|
||||
void on_request_firebase_sms_result(NetQueryPtr &result);
|
||||
void on_authentication_result(NetQueryPtr &result, bool is_from_current_query);
|
||||
void on_log_out_result(NetQueryPtr &result);
|
||||
void on_delete_account_result(NetQueryPtr &result);
|
||||
|
@ -94,6 +94,21 @@ telegram_api::auth_sendCode SendCodeHelper::send_code(string phone_number, const
|
||||
return telegram_api::auth_sendCode(phone_number_, api_id, api_hash, get_input_code_settings(settings));
|
||||
}
|
||||
|
||||
telegram_api::auth_requestFirebaseSms SendCodeHelper::request_firebase_sms(const string &token) {
|
||||
string safety_net_token;
|
||||
string ios_push_secret;
|
||||
int32 flags = 0;
|
||||
#if TD_ANDROID
|
||||
flags |= telegram_api::auth_requestFirebaseSms::SAFETY_NET_TOKEN_MASK;
|
||||
safety_net_token = token;
|
||||
#elif TD_DARWIN
|
||||
flags |= telegram_api::auth_requestFirebaseSms::IOS_PUSH_SECRET_MASK;
|
||||
ios_push_secret = token;
|
||||
#endif
|
||||
return telegram_api::auth_requestFirebaseSms(flags, phone_number_, phone_code_hash_, safety_net_token,
|
||||
ios_push_secret);
|
||||
}
|
||||
|
||||
telegram_api::account_sendVerifyEmailCode SendCodeHelper::send_verify_email_code(const string &email_address) {
|
||||
return telegram_api::account_sendVerifyEmailCode(get_email_verify_purpose_login_setup(), email_address);
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ class SendCodeHelper {
|
||||
telegram_api::auth_sendCode send_code(string phone_number, const Settings &settings, int32 api_id,
|
||||
const string &api_hash);
|
||||
|
||||
telegram_api::auth_requestFirebaseSms request_firebase_sms(const string &token);
|
||||
|
||||
telegram_api::account_sendVerifyEmailCode send_verify_email_code(const string &email_address);
|
||||
|
||||
telegram_api::account_sendChangePhoneCode send_change_phone_code(Slice phone_number, const Settings &settings);
|
||||
|
@ -2759,6 +2759,7 @@ bool Td::is_authentication_request(int32 id) {
|
||||
case td_api::setTdlibParameters::ID:
|
||||
case td_api::getAuthorizationState::ID:
|
||||
case td_api::setAuthenticationPhoneNumber::ID:
|
||||
case td_api::sendAuthenticationFirebaseSms::ID:
|
||||
case td_api::setAuthenticationEmailAddress::ID:
|
||||
case td_api::resendAuthenticationCode::ID:
|
||||
case td_api::checkAuthenticationEmailCode::ID:
|
||||
@ -4164,6 +4165,11 @@ void Td::on_request(uint64 id, td_api::setAuthenticationPhoneNumber &request) {
|
||||
std::move(request.settings_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::sendAuthenticationFirebaseSms &request) {
|
||||
CLEAN_INPUT_STRING(request.token_);
|
||||
send_closure(auth_manager_actor_, &AuthManager::set_firebase_token, id, std::move(request.token_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setAuthenticationEmailAddress &request) {
|
||||
CLEAN_INPUT_STRING(request.email_address_);
|
||||
send_closure(auth_manager_actor_, &AuthManager::set_email_address, id, std::move(request.email_address_));
|
||||
|
@ -399,6 +399,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::setAuthenticationPhoneNumber &request);
|
||||
|
||||
void on_request(uint64 id, td_api::sendAuthenticationFirebaseSms &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setAuthenticationEmailAddress &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::resendAuthenticationCode &request);
|
||||
|
Loading…
Reference in New Issue
Block a user