adding phone numbers does not work

This commit is contained in:
Carson McManus 2021-08-09 21:41:20 -04:00
parent c17bdf92a5
commit 691d927050
3 changed files with 41 additions and 22 deletions

View file

@ -142,8 +142,9 @@ fn main() {
return;
}
Err(AccountLinkError::MustProvidePhoneNumber) => {
print!("Enter your phone number: ");
linker.phone_number = prompt();
println!("Enter your phone number in the following format: +1 123-456-7890");
print!("Phone number: ");
linker.phone_number = prompt().replace(&['(', ')', '-'][..], "");
}
Err(AccountLinkError::AuthenticatorPresent) => {
println!("An authenticator is already present on this account.");

View file

@ -32,27 +32,27 @@ impl AccountLinker {
}
pub fn link(&mut self) -> anyhow::Result<SteamGuardAccount, AccountLinkError> {
let has_phone = self.client.has_phone()?;
// let has_phone = self.client.has_phone()?;
if has_phone && !self.phone_number.is_empty() {
return Err(AccountLinkError::MustRemovePhoneNumber);
}
if !has_phone && self.phone_number.is_empty() {
return Err(AccountLinkError::MustProvidePhoneNumber);
}
// if has_phone && !self.phone_number.is_empty() {
// return Err(AccountLinkError::MustRemovePhoneNumber);
// }
// if !has_phone && self.phone_number.is_empty() {
// return Err(AccountLinkError::MustProvidePhoneNumber);
// }
if !has_phone {
if self.sent_confirmation_email {
if !self.client.check_email_confirmation()? {
return Err(anyhow!("Failed email confirmation check"))?;
}
} else if !self.client.add_phone_number(self.phone_number.clone())? {
return Err(anyhow!("Failed to add phone number"))?;
} else {
self.sent_confirmation_email = true;
return Err(AccountLinkError::MustConfirmEmail);
}
}
// if !has_phone {
// if self.sent_confirmation_email {
// if !self.client.check_email_confirmation()? {
// return Err(anyhow!("Failed email confirmation check"))?;
// }
// } else if !self.client.add_phone_number(self.phone_number.clone())? {
// return Err(anyhow!("Failed to add phone number"))?;
// } else {
// self.sent_confirmation_email = true;
// return Err(AccountLinkError::MustConfirmEmail);
// }
// }
let resp: AddAuthenticatorResponse =
self.client.add_authenticator(self.device_id.clone())?;

View file

@ -301,6 +301,9 @@ impl SteamApiClient {
}
}
/// One of the endpoints that handles phone number things. Can check to see if phone is present on account, and maybe do some other stuff. It's not really super clear.
///
/// Host: steamcommunity.com
/// Endpoint: POST /steamguard/phoneajax
/// Requires `sessionid` cookie to be set.
fn phoneajax(&self, op: &str, arg: &str) -> anyhow::Result<bool> {
@ -319,6 +322,7 @@ impl SteamApiClient {
.form(&params)
.send()?;
trace!("phoneajax: status={}", resp.status());
let result: Value = resp.json()?;
trace!("phoneajax: {:?}", result);
if result["has_phone"] != Value::Null {
@ -350,7 +354,21 @@ impl SteamApiClient {
}
pub fn add_phone_number(&self, phone_number: String) -> anyhow::Result<bool> {
return self.phoneajax("add_phone_number", phone_number.as_str());
// return self.phoneajax("add_phone_number", phone_number.as_str());
todo!();
}
/// Provides lots of juicy information, like if the number is a VOIP number.
/// Host: store.steampowered.com
/// Endpoint: POST /phone/validate
/// Found on page: https://store.steampowered.com/phone/add
pub fn phone_validate(&self, phone_number: String) -> anyhow::Result<bool> {
let params = hashmap!{
"sessionID" => "",
"phoneNumber" => "",
};
todo!();
}
/// Starts the authenticator linking process.