format: paket login
This commit is contained in:
parent
daa2aedf0c
commit
a57be17dab
1 changed files with 24 additions and 10 deletions
|
@ -129,23 +129,27 @@ impl AsyncComponent for Login {
|
|||
} else {
|
||||
match keyring
|
||||
.search_items(&HashMap::from(KEYRING_ATTRIBUTES))
|
||||
.await {
|
||||
.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");
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue