From a57be17dab42c0b534e7d1d63279a2cf0c29485c Mon Sep 17 00:00:00 2001 From: jane400 Date: Sun, 18 Aug 2024 18:04:06 +0200 Subject: [PATCH] format: paket login --- paket/src/login.rs | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/paket/src/login.rs b/paket/src/login.rs index e7fc8a5..903cddf 100644 --- a/paket/src/login.rs +++ b/paket/src/login.rs @@ -128,24 +128,28 @@ impl AsyncComponent for Login { .expect("sender not worky"); } else { match keyring - .search_items(&HashMap::from(KEYRING_ATTRIBUTES)) - .await { + .search_items(&HashMap::from(KEYRING_ATTRIBUTES)) + .await + { Ok(res) => { if res.len() > 0 { let item = &res[0]; let refresh_token = item.secret().await.unwrap(); - let refresh_token = std::str::from_utf8(refresh_token.as_slice()).unwrap(); - model.refresh_token = Some(RefreshToken::new(refresh_token.to_string()).unwrap()); + let refresh_token = + std::str::from_utf8(refresh_token.as_slice()).unwrap(); + model.refresh_token = Some( + RefreshToken::new(refresh_token.to_string()).unwrap(), + ); sender.input(LoginInput::NeedsRefresh); } else { sender.input(LoginInput::NeedsLogin); } - }, + } Err(err) => { sender - .output(LoginOutput::KeyringError(err)) - .expect("sender not worky"); - }, + .output(LoginOutput::KeyringError(err)) + .expect("sender not worky"); + } }; } } @@ -208,7 +212,9 @@ impl AsyncComponent for Login { } LoginInput::BreakWorld => { self.set_state(LoginState::Offline); - sender.output(LoginOutput::Error(libpaket::LibraryError::APIChange)).unwrap(); + sender + .output(LoginOutput::Error(libpaket::LibraryError::APIChange)) + .unwrap(); { let shared_id_token = self.shared_id_token.lock().await; let mut shared_id_token = shared_id_token.write(); @@ -294,7 +300,15 @@ impl Login { let future = async { self.refresh_token = Some(res.refresh_token); let keyring = KEYRING.get().unwrap(); - keyring.create_item("Refresh Token", &HashMap::from(KEYRING_ATTRIBUTES), self.refresh_token.as_ref().unwrap().to_string(), true).await.unwrap(); + keyring + .create_item( + "Refresh Token", + &HashMap::from(KEYRING_ATTRIBUTES), + self.refresh_token.as_ref().unwrap().to_string(), + true, + ) + .await + .unwrap(); }; if !res.id_token.is_expired() {