aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/plugins/login.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2026-01-01 22:28:53 -0600
committerGitHub <noreply@github.com>2026-01-01 22:28:53 -0600
commit1ca1f1d9e27aeea3adaf359570f2e211e0a9af74 (patch)
treedd35bb9bff67f0622a6410c99b5bd1678c9c8299 /azalea-client/src/plugins/login.rs
parent7b84235a9be5bdc7c05873467ad8310b57448d79 (diff)
downloadazalea-drasl-1ca1f1d9e27aeea3adaf359570f2e211e0a9af74.tar.xz
Extensible Account (#301)
* refactor Account * clean up implementation and docs * add AccountTrait::join * update changelog * update example
Diffstat (limited to 'azalea-client/src/plugins/login.rs')
-rw-r--r--azalea-client/src/plugins/login.rs28
1 files changed, 9 insertions, 19 deletions
diff --git a/azalea-client/src/plugins/login.rs b/azalea-client/src/plugins/login.rs
index 5bfefe44..b301d94b 100644
--- a/azalea-client/src/plugins/login.rs
+++ b/azalea-client/src/plugins/login.rs
@@ -14,7 +14,7 @@ use super::{
connection::RawConnection,
packet::login::{ReceiveCustomQueryEvent, ReceiveHelloEvent, SendLoginPacketEvent},
};
-use crate::{Account, join::ConnectOpts};
+use crate::{account::Account, join::ConnectOpts};
/// Some systems that run during the `login` state.
pub struct LoginPlugin;
@@ -46,7 +46,7 @@ fn handle_receive_hello_event(
None
};
- let task = task_pool.spawn(auth_with_account(account, packet, connect_opts));
+ let task = task_pool.spawn(async { auth_with_account(account, packet, connect_opts).await });
commands.entity(client).insert(AuthTask(task));
}
@@ -123,7 +123,7 @@ pub async fn auth_with_account(
#[cfg(feature = "online-mode")]
if packet.should_authenticate {
- let Some(access_token) = &account.access_token else {
+ if account.access_token().is_none() {
// offline mode account, no need to do auth
return Ok((key_packet, private_key));
};
@@ -135,26 +135,15 @@ pub async fn auth_with_account(
let proxy = proxy.map(Proxy::into);
while let Err(err) = {
- use azalea_auth::sessionserver::{self, SessionServerJoinOpts};
-
- let access_token = access_token.lock().clone();
-
- let uuid = &account
- .uuid
- .expect("Uuid must be present if access token is present.");
-
let proxy = proxy.clone();
// this is necessary since reqwest usually depends on tokio and we're using
// `futures` here
- async_compat::Compat::new(sessionserver::join(SessionServerJoinOpts {
- access_token: &access_token,
- public_key: &packet.public_key,
- private_key: &private_key,
- uuid,
- server_id: &packet.server_id,
- proxy,
- }))
+ async_compat::Compat::new(async {
+ account
+ .join(&packet.public_key, &private_key, &packet.server_id, proxy)
+ .await
+ })
.await
} {
if attempts >= 2 {
@@ -169,6 +158,7 @@ pub async fn auth_with_account(
) {
// uh oh, we got an invalid session and have
// to reauthenticate now
+
async_compat::Compat::new(account.refresh()).await?;
} else {
return Err(err.into());