Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trade: if confirmation failure response contains a message, keep it so the user can see it #329

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions steamguard/src/confirmation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ where
return Err(ConfirmerError::InvalidTokens);
}
if !body.success {
return Err(ConfirmerError::RemoteFailure);
if let Some(msg) = body.message {
return Err(ConfirmerError::RemoteFailureWithMessage(msg));
} else {
return Err(ConfirmerError::RemoteFailure);
}
}
Ok(body.conf)
}
Expand Down Expand Up @@ -162,7 +166,11 @@ where
return Err(ConfirmerError::InvalidTokens);
}
if !body.success {
return Err(ConfirmerError::RemoteFailure);
if let Some(msg) = body.message {
return Err(ConfirmerError::RemoteFailureWithMessage(msg));
} else {
return Err(ConfirmerError::RemoteFailure);
}
}

Ok(())
Expand Down Expand Up @@ -237,7 +245,11 @@ where
return Err(ConfirmerError::InvalidTokens);
}
if !body.success {
return Err(ConfirmerError::RemoteFailure);
if let Some(msg) = body.message {
return Err(ConfirmerError::RemoteFailureWithMessage(msg));
} else {
return Err(ConfirmerError::RemoteFailure);
}
}

Ok(())
Expand Down Expand Up @@ -316,8 +328,10 @@ pub enum ConfirmerError {
NetworkFailure(#[from] reqwest::Error),
#[error("Failed to deserialize response: {0}")]
DeserializeError(#[from] serde_path_to_error::Error<serde_json::Error>),
#[error("Remote failure: Valve's server responded with a failure. This is likely not a steamguard-cli bug, Steam's confirmation API is just unreliable. Wait a bit and try again.")]
#[error("Remote failure: Valve's server responded with a failure and did not elaborate any further. This is likely not a steamguard-cli bug, Steam's confirmation API is just unreliable. Wait a bit and try again.")]
RemoteFailure,
#[error("Remote failure: Valve's server responded with a failure and said: {0}")]
RemoteFailureWithMessage(String),
#[error("Unknown error: {0}")]
Unknown(#[from] anyhow::Error),
}
Expand Down Expand Up @@ -388,13 +402,17 @@ pub struct ConfirmationListResponse {
pub needauth: Option<bool>,
#[serde(default)]
pub conf: Vec<Confirmation>,
#[serde(default)]
pub message: Option<String>,
}

#[derive(Debug, Clone, Copy, Deserialize)]
#[derive(Debug, Clone, Deserialize)]
pub struct SendConfirmationResponse {
pub success: bool,
#[serde(default)]
pub needsauth: Option<bool>,
#[serde(default)]
pub message: Option<String>,
}

fn build_time_bytes(time: u64) -> [u8; 8] {
Expand Down
Loading