diff --git a/src-tauri/src/auth.rs b/src-tauri/src/auth.rs index 020e656..1e9df5a 100644 --- a/src-tauri/src/auth.rs +++ b/src-tauri/src/auth.rs @@ -13,7 +13,7 @@ use url::Url; use crate::{ db::{DatabaseAuth, DatabaseImpls}, - remote::RemoteAccessError, + remote::{DropServerError, RemoteAccessError}, AppState, AppStatus, User, DB, }; @@ -78,7 +78,13 @@ pub fn fetch_user() -> Result { .send()?; if response.status() != 200 { - info!("Could not fetch user: {}", response.text().unwrap()); + let data = response.json::()?; + info!("Could not fetch user: {}", data.status_message); + + if data.status_message == "Nonce expired" { + return Err(RemoteAccessError::OutOfSync); + } + return Err(RemoteAccessError::InvalidCodeError(0)); } diff --git a/src-tauri/src/remote.rs b/src-tauri/src/remote.rs index f62e6e2..2d51443 100644 --- a/src-tauri/src/remote.rs +++ b/src-tauri/src/remote.rs @@ -22,6 +22,7 @@ pub enum RemoteAccessError { InvalidResponse, InvalidRedirect, ManifestDownloadFailed(StatusCode, String), + OutOfSync, } impl Display for RemoteAccessError { @@ -51,6 +52,7 @@ impl Display for RemoteAccessError { "Failed to download game manifest: {} {}", status, response ), + RemoteAccessError::OutOfSync => write!(f, "Server's and client's time are out of sync. Please ensure they are within at least 30 seconds of each other."), } } } @@ -73,6 +75,15 @@ impl From for RemoteAccessError { impl std::error::Error for RemoteAccessError {} +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct DropServerError { + pub status_code: usize, + pub status_message: String, + pub message: String, + pub url: String, +} + #[derive(Deserialize)] #[serde(rename_all = "camelCase")] struct DropHealthcheck {