diff --git a/apps/gpauth/src/auth_window.rs b/apps/gpauth/src/auth_window.rs index c3a7675..c326195 100644 --- a/apps/gpauth/src/auth_window.rs +++ b/apps/gpauth/src/auth_window.rs @@ -366,17 +366,14 @@ fn read_auth_data_from_html(html: &str) -> Result Ok(auth_data), - Err(err) => { - if let Some(gpcallback) = extract_gpcallback(html) { - info!("Found gpcallback from html..."); - SamlAuthData::from_gpcallback(&gpcallback) - } else { - Err(err) - } + SamlAuthData::from_html(html).or_else(|err| { + if let Some(gpcallback) = extract_gpcallback(html) { + info!("Found gpcallback from html..."); + SamlAuthData::from_gpcallback(&gpcallback) + } else { + Err(err) } - } + }) } fn extract_gpcallback(html: &str) -> Option { diff --git a/crates/gpapi/src/credential.rs b/crates/gpapi/src/credential.rs index 2982b55..93a06df 100644 --- a/crates/gpapi/src/credential.rs +++ b/crates/gpapi/src/credential.rs @@ -162,7 +162,7 @@ pub enum Credential { Password(PasswordCredential), Prelogin(PreloginCredential), AuthCookie(AuthCookieCredential), - CachedCredential(CachedCredential), + Cached(CachedCredential), } impl Credential { @@ -179,7 +179,7 @@ impl Credential { Credential::Password(cred) => cred.username(), Credential::Prelogin(cred) => cred.username(), Credential::AuthCookie(cred) => cred.username(), - Credential::CachedCredential(cred) => cred.username(), + Credential::Cached(cred) => cred.username(), } } @@ -197,7 +197,7 @@ impl Credential { Some(cred.prelogon_user_auth_cookie()), None, ), - Credential::CachedCredential(cred) => ( + Credential::Cached(cred) => ( cred.password(), None, Some(cred.auth_cookie.user_auth_cookie()), @@ -244,6 +244,6 @@ impl From<&AuthCookieCredential> for Credential { impl From<&CachedCredential> for Credential { fn from(value: &CachedCredential) -> Self { - Self::CachedCredential(value.clone()) + Self::Cached(value.clone()) } } diff --git a/crates/gpapi/src/gp_params.rs b/crates/gpapi/src/gp_params.rs index 12b9329..59b9f34 100644 --- a/crates/gpapi/src/gp_params.rs +++ b/crates/gpapi/src/gp_params.rs @@ -130,13 +130,15 @@ pub struct GpParamsBuilder { impl GpParamsBuilder { pub fn new() -> Self { + let computer = whoami::fallible::hostname().unwrap_or_else(|_| String::from("localhost")); + Self { is_gateway: false, user_agent: GP_USER_AGENT.to_string(), client_os: ClientOs::Linux, os_version: Default::default(), client_version: Default::default(), - computer: whoami::hostname(), + computer, ignore_tls_errors: false, } }