summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2025-02-13 17:08:53 -0600
committerLibravatar bigfoot547 <[email protected]>2025-02-13 17:08:53 -0600
commita7e374d28d1691f350536129cd77a5c9447524ae (patch)
tree47e8569e2b1458c2311eb0d79c6284d0d3b1b40a
parentwip: account management cli (diff)
minor changes
-rw-r--r--ozone/src/auth.rs25
-rw-r--r--ozone/src/auth/types.rs19
2 files changed, 25 insertions, 19 deletions
diff --git a/ozone/src/auth.rs b/ozone/src/auth.rs
index cb905af..ca06e93 100644
--- a/ozone/src/auth.rs
+++ b/ozone/src/auth.rs
@@ -56,9 +56,9 @@ impl MsaAccount {
let to_scope = |f: &&str| Scope::new(String::from(*f));
if self.is_azure_client_id {
- AZURE_LOGIN_SCOPES.into_iter().map(to_scope)
+ AZURE_LOGIN_SCOPES.iter().map(to_scope)
} else {
- NON_AZURE_LOGIN_SCOPES.into_iter().map(to_scope)
+ NON_AZURE_LOGIN_SCOPES.iter().map(to_scope)
}
}
@@ -84,10 +84,8 @@ impl MsaAccount {
.request_async(client)
.await.map_err(|e| match e {
RequestTokenError::ServerResponse(res)
- if match res.error() {
- BasicErrorResponseType::Extension(s) if s == "interaction_required" || s == "consent_required" => true,
- _ => false
- } => AuthError::raw_msg(AuthErrorKind::InteractionRequired, "microsoft requested interactive login"),
+ if matches!(res.error(), BasicErrorResponseType::Extension(s) if s == "interaction_required" || s == "consent_required") =>
+ AuthError::raw_msg(AuthErrorKind::InteractionRequired, "microsoft requested interactive login"),
_ => AuthError::internal_msg_src("refresh", e)
})?;
@@ -228,7 +226,6 @@ impl MsaAccount {
#[cfg(test)]
mod test {
- use oauth2::ClientId;
use super::*;
#[tokio::test]
@@ -238,18 +235,8 @@ mod test {
let mut user = match tokio::fs::read_to_string("../test_stuff/test.json").await {
Ok(s) => serde_json::from_str::<MsaAccount>(&s).unwrap(),
Err(e) if e.kind() == tokio::io::ErrorKind::NotFound => {
- MsaAccount {
- player_profile: None,
- xuid: None,
- gamertag: None,
- player_info: None,
- //client_id: ClientId::new("00000000402b5328".into()),
- client_id: ClientId::new("60b6cc54-fc07-4bab-bca9-cbe9aa713c80".into()),
- is_azure_client_id: true,
- mc_token: None,
- xbl_token: None,
- refresh_token: None
- }
+ //MsaAccount::with_client_id("00000000402b5328", false)
+ MsaAccount::with_client_id("60b6cc54-fc07-4bab-bca9-cbe9aa713c80", true)
},
Err(e) => panic!("i/o error: {}", e)
};
diff --git a/ozone/src/auth/types.rs b/ozone/src/auth/types.rs
index fa73c45..134c45a 100644
--- a/ozone/src/auth/types.rs
+++ b/ozone/src/auth/types.rs
@@ -131,6 +131,25 @@ pub struct MsaAccount {
pub(super) refresh_token: Option<RefreshToken>
}
+impl MsaAccount {
+ pub fn with_client_id(client_id: &str, azure: bool) -> MsaAccount {
+ MsaAccount {
+ player_profile: None,
+ xuid: None,
+ gamertag: None,
+
+ player_info: None,
+
+ client_id: oauth2::ClientId::new(client_id.to_string()),
+ is_azure_client_id: azure,
+
+ mc_token: None,
+ xbl_token: None,
+ refresh_token: None
+ }
+ }
+}
+
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "lowercase")]
pub enum Account {