From 3376da2da2fd031e3b805feefdaef27e90390c44 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Thu, 25 Mar 2021 15:26:45 -0400 Subject: [PATCH] add data to login results --- src/steamapi.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/steamapi.rs b/src/steamapi.rs index fb9577c..e1a021a 100644 --- a/src/steamapi.rs +++ b/src/steamapi.rs @@ -38,10 +38,10 @@ struct RsaResponse { #[derive(Debug)] pub enum LoginResult { - Ok, + Ok{ session: Session }, BadRSA, BadCredentials, - NeedCaptcha, + NeedCaptcha{ captcha_gid: String }, Need2FA, NeedEmail, TooManyAttempts, @@ -103,7 +103,7 @@ impl UserLogin { pub fn login(&self) -> LoginResult { if self.captcha_required && self.captcha_text.len() == 0 { - return LoginResult::NeedCaptcha; + return LoginResult::NeedCaptcha{captcha_gid: self.captcha_gid}; } let url = "https://steamcommunity.com".parse::().unwrap(); @@ -187,7 +187,8 @@ impl UserLogin { } if login_resp.captcha_needed { - return LoginResult::NeedCaptcha; + self.captcha_gid = login_resp.captcha_gid; + return LoginResult::NeedCaptcha{ captcha_gid: self.captcha_gid }; } if login_resp.emailauth_needed { @@ -205,7 +206,7 @@ impl UserLogin { let oauth: OAuthData = serde_json::from_str(login_resp.oauth).unwrap(); let session = self.build_session(oauth); - return LoginResult::Ok; + return LoginResult::Ok{session}; } fn build_session(&self, data: OAuthData) -> Session {