Add handle to resume request.

This commit is contained in:
yukirij 2024-10-13 11:03:27 -07:00
parent 64c9d71941
commit 9feb88d81a
3 changed files with 19 additions and 2 deletions

View File

@ -345,6 +345,8 @@ pub async fn thread_system(mut app:App, bus:Bus<protocol::QRPacket>)
} { } {
// Add connection to chain. // Add connection to chain.
if let Some(user) = app.get_user_by_id(auth.user).cloned() { 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(user_cid) = user.connection {
if let Some(existing) = app.connections.get(user_cid as usize).cloned() { if let Some(existing) = app.connections.get(user_cid as usize).cloned() {
if let Some(conn) = app.connections.get_mut(qr.id as usize) { if let Some(conn) = app.connections.get_mut(qr.id as usize) {

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
app::authentication::{AuthToken, AuthSecret}, app::authentication::{AuthToken, AuthSecret},
util::pack::pack_u16, util::pack::{pack_u8, pack_u16},
}; };
use super::Packet; use super::Packet;
@ -40,12 +40,14 @@ impl Packet for PacketAuthResume {
#[derive(Clone)] #[derive(Clone)]
pub struct PacketAuthResumeResponse { pub struct PacketAuthResumeResponse {
pub status:u16, pub status:u16,
pub handle:String,
} }
impl PacketAuthResumeResponse { impl PacketAuthResumeResponse {
pub fn new() -> Self pub fn new() -> Self
{ {
Self { Self {
status:0, status:0,
handle:String::new(),
} }
} }
} }
@ -54,8 +56,11 @@ impl Packet for PacketAuthResumeResponse {
fn encode(&self) -> Vec<u8> fn encode(&self) -> Vec<u8>
{ {
let handle_bytes = self.handle.as_bytes().to_vec();
[ [
pack_u16(self.status), pack_u16(self.status),
pack_u8(handle_bytes.len() as u8),
handle_bytes,
].concat() ].concat()
} }
} }

View File

@ -127,9 +127,19 @@ function MESSAGE(event) {
case OpCode.Resume: { case OpCode.Resume: {
console.log("RECV Resume"); console.log("RECV Resume");
// Status
result = UNPACK.u16(bytes, index); result = UNPACK.u16(bytes, index);
index = result.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(); sessionStorage.clear();
} }