diff --git a/server/src/manager/data.rs b/server/src/manager/data.rs index 68262e4..2ddb4fa 100644 --- a/server/src/manager/data.rs +++ b/server/src/manager/data.rs @@ -345,6 +345,8 @@ pub async fn thread_system(mut app:App, bus:Bus) } { // Add connection to chain. if let Some(user) = app.get_user_by_id(auth.user).cloned() { + response.handle = user.handle.clone(); + if let Some(user_cid) = user.connection { if let Some(existing) = app.connections.get(user_cid as usize).cloned() { if let Some(conn) = app.connections.get_mut(qr.id as usize) { diff --git a/server/src/protocol/packet/resume.rs b/server/src/protocol/packet/resume.rs index b7ef156..584dfbb 100644 --- a/server/src/protocol/packet/resume.rs +++ b/server/src/protocol/packet/resume.rs @@ -1,6 +1,6 @@ use crate::{ app::authentication::{AuthToken, AuthSecret}, - util::pack::pack_u16, + util::pack::{pack_u8, pack_u16}, }; use super::Packet; @@ -40,12 +40,14 @@ impl Packet for PacketAuthResume { #[derive(Clone)] pub struct PacketAuthResumeResponse { pub status:u16, + pub handle:String, } impl PacketAuthResumeResponse { pub fn new() -> Self { Self { status:0, + handle:String::new(), } } } @@ -54,8 +56,11 @@ impl Packet for PacketAuthResumeResponse { fn encode(&self) -> Vec { + let handle_bytes = self.handle.as_bytes().to_vec(); [ pack_u16(self.status), + pack_u8(handle_bytes.len() as u8), + handle_bytes, ].concat() } } diff --git a/www/js/system.js b/www/js/system.js index 608f1d8..aa99d94 100644 --- a/www/js/system.js +++ b/www/js/system.js @@ -127,9 +127,19 @@ function MESSAGE(event) { case OpCode.Resume: { console.log("RECV Resume"); + // Status result = UNPACK.u16(bytes, index); index = result.index; - if(result.data != Status.Ok) { + if(result.data == Status.Ok) { + CONTEXT.Auth = { + handle: "", + }; + + // User Handle + result = UNPACK.string(bytes, index, UNPACK.u8); + index = result.index; + CONTEXT.Auth.handle = result.data; + } else { sessionStorage.clear(); }