adding phone numbers does not work
This commit is contained in:
parent
c17bdf92a5
commit
691d927050
3 changed files with 41 additions and 22 deletions
|
@ -142,8 +142,9 @@ fn main() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Err(AccountLinkError::MustProvidePhoneNumber) => {
|
Err(AccountLinkError::MustProvidePhoneNumber) => {
|
||||||
print!("Enter your phone number: ");
|
println!("Enter your phone number in the following format: +1 123-456-7890");
|
||||||
linker.phone_number = prompt();
|
print!("Phone number: ");
|
||||||
|
linker.phone_number = prompt().replace(&['(', ')', '-'][..], "");
|
||||||
}
|
}
|
||||||
Err(AccountLinkError::AuthenticatorPresent) => {
|
Err(AccountLinkError::AuthenticatorPresent) => {
|
||||||
println!("An authenticator is already present on this account.");
|
println!("An authenticator is already present on this account.");
|
||||||
|
|
|
@ -32,27 +32,27 @@ impl AccountLinker {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn link(&mut self) -> anyhow::Result<SteamGuardAccount, AccountLinkError> {
|
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() {
|
// if has_phone && !self.phone_number.is_empty() {
|
||||||
return Err(AccountLinkError::MustRemovePhoneNumber);
|
// return Err(AccountLinkError::MustRemovePhoneNumber);
|
||||||
}
|
// }
|
||||||
if !has_phone && self.phone_number.is_empty() {
|
// if !has_phone && self.phone_number.is_empty() {
|
||||||
return Err(AccountLinkError::MustProvidePhoneNumber);
|
// return Err(AccountLinkError::MustProvidePhoneNumber);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if !has_phone {
|
// if !has_phone {
|
||||||
if self.sent_confirmation_email {
|
// if self.sent_confirmation_email {
|
||||||
if !self.client.check_email_confirmation()? {
|
// if !self.client.check_email_confirmation()? {
|
||||||
return Err(anyhow!("Failed email confirmation check"))?;
|
// return Err(anyhow!("Failed email confirmation check"))?;
|
||||||
}
|
// }
|
||||||
} else if !self.client.add_phone_number(self.phone_number.clone())? {
|
// } else if !self.client.add_phone_number(self.phone_number.clone())? {
|
||||||
return Err(anyhow!("Failed to add phone number"))?;
|
// return Err(anyhow!("Failed to add phone number"))?;
|
||||||
} else {
|
// } else {
|
||||||
self.sent_confirmation_email = true;
|
// self.sent_confirmation_email = true;
|
||||||
return Err(AccountLinkError::MustConfirmEmail);
|
// return Err(AccountLinkError::MustConfirmEmail);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
let resp: AddAuthenticatorResponse =
|
let resp: AddAuthenticatorResponse =
|
||||||
self.client.add_authenticator(self.device_id.clone())?;
|
self.client.add_authenticator(self.device_id.clone())?;
|
||||||
|
|
|
@ -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
|
/// Endpoint: POST /steamguard/phoneajax
|
||||||
/// Requires `sessionid` cookie to be set.
|
/// Requires `sessionid` cookie to be set.
|
||||||
fn phoneajax(&self, op: &str, arg: &str) -> anyhow::Result<bool> {
|
fn phoneajax(&self, op: &str, arg: &str) -> anyhow::Result<bool> {
|
||||||
|
@ -319,6 +322,7 @@ impl SteamApiClient {
|
||||||
.form(¶ms)
|
.form(¶ms)
|
||||||
.send()?;
|
.send()?;
|
||||||
|
|
||||||
|
trace!("phoneajax: status={}", resp.status());
|
||||||
let result: Value = resp.json()?;
|
let result: Value = resp.json()?;
|
||||||
trace!("phoneajax: {:?}", result);
|
trace!("phoneajax: {:?}", result);
|
||||||
if result["has_phone"] != Value::Null {
|
if result["has_phone"] != Value::Null {
|
||||||
|
@ -350,7 +354,21 @@ impl SteamApiClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_phone_number(&self, phone_number: String) -> anyhow::Result<bool> {
|
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.
|
/// Starts the authenticator linking process.
|
||||||
|
|
Loading…
Reference in a new issue