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 {
|
} else {
|
||||||
match keyring
|
match keyring
|
||||||
.search_items(&HashMap::from(KEYRING_ATTRIBUTES))
|
.search_items(&HashMap::from(KEYRING_ATTRIBUTES))
|
||||||
.await {
|
.await
|
||||||
|
{
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
if res.len() > 0 {
|
if res.len() > 0 {
|
||||||
let item = &res[0];
|
let item = &res[0];
|
||||||
let refresh_token = item.secret().await.unwrap();
|
let refresh_token = item.secret().await.unwrap();
|
||||||
let refresh_token = std::str::from_utf8(refresh_token.as_slice()).unwrap();
|
let refresh_token =
|
||||||
model.refresh_token = Some(RefreshToken::new(refresh_token.to_string()).unwrap());
|
std::str::from_utf8(refresh_token.as_slice()).unwrap();
|
||||||
|
model.refresh_token = Some(
|
||||||
|
RefreshToken::new(refresh_token.to_string()).unwrap(),
|
||||||
|
);
|
||||||
sender.input(LoginInput::NeedsRefresh);
|
sender.input(LoginInput::NeedsRefresh);
|
||||||
} else {
|
} else {
|
||||||
sender.input(LoginInput::NeedsLogin);
|
sender.input(LoginInput::NeedsLogin);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
sender
|
sender
|
||||||
.output(LoginOutput::KeyringError(err))
|
.output(LoginOutput::KeyringError(err))
|
||||||
.expect("sender not worky");
|
.expect("sender not worky");
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,7 +212,9 @@ impl AsyncComponent for Login {
|
||||||
}
|
}
|
||||||
LoginInput::BreakWorld => {
|
LoginInput::BreakWorld => {
|
||||||
self.set_state(LoginState::Offline);
|
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 shared_id_token = self.shared_id_token.lock().await;
|
||||||
let mut shared_id_token = shared_id_token.write();
|
let mut shared_id_token = shared_id_token.write();
|
||||||
|
@ -294,7 +300,15 @@ impl Login {
|
||||||
let future = async {
|
let future = async {
|
||||||
self.refresh_token = Some(res.refresh_token);
|
self.refresh_token = Some(res.refresh_token);
|
||||||
let keyring = KEYRING.get().unwrap();
|
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() {
|
if !res.id_token.is_expired() {
|
||||||
|
|
Loading…
Reference in a new issue