diff options
| author | mat <git@matdoes.dev> | 2025-05-30 19:36:59 -0800 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-05-30 19:36:59 -0800 |
| commit | ae4b1e85e669bc882d158509ef1eda46c6b2a72e (patch) | |
| tree | adf81cc01b0ce1575e95b99ad109fd92db1738f6 /azalea-auth/src/auth.rs | |
| parent | a64c6505049082175224802c5be51ac8f0cf4677 (diff) | |
| download | azalea-drasl-ae4b1e85e669bc882d158509ef1eda46c6b2a72e.tar.xz | |
fix clippy issues and improve formatting everywhere
Diffstat (limited to 'azalea-auth/src/auth.rs')
| -rw-r--r-- | azalea-auth/src/auth.rs | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/azalea-auth/src/auth.rs b/azalea-auth/src/auth.rs index 99dfc115..51e44a70 100644 --- a/azalea-auth/src/auth.rs +++ b/azalea-auth/src/auth.rs @@ -3,13 +3,14 @@ use std::{ collections::HashMap, path::PathBuf, - time::{Instant, SystemTime, UNIX_EPOCH}, + time::{Duration, Instant, SystemTime, UNIX_EPOCH}, }; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use serde_json::json; use thiserror::Error; +use tokio::time::sleep; use tracing::{error, trace}; use uuid::Uuid; @@ -75,8 +76,9 @@ pub async fn auth(email: &str, opts: AuthOpts<'_>) -> Result<AuthResult, AuthErr None }; - if cached_account.is_some() && !cached_account.as_ref().unwrap().mca.is_expired() { - let account = cached_account.as_ref().unwrap(); + if let Some(account) = &cached_account + && !account.mca.is_expired() + { // the minecraft auth data is cached and not expired, so we can just // use that instead of doing auth all over again :) @@ -129,8 +131,8 @@ pub async fn auth(email: &str, opts: AuthOpts<'_>) -> Result<AuthResult, AuthErr let profile: ProfileResponse = get_profile(&client, &res.minecraft_access_token).await?; - if let Some(cache_file) = opts.cache_file { - if let Err(e) = cache::set_account_in_cache( + if let Some(cache_file) = opts.cache_file + && let Err(e) = cache::set_account_in_cache( &cache_file, email, CachedAccount { @@ -142,9 +144,8 @@ pub async fn auth(email: &str, opts: AuthOpts<'_>) -> Result<AuthResult, AuthErr }, ) .await - { - error!("{}", e); - } + { + error!("{}", e); } Ok(AuthResult { @@ -328,7 +329,7 @@ pub async fn get_ms_link_code( Ok(client .post("https://login.live.com/oauth20_connect.srf") - .form(&vec