Add handle to resume request.
This commit is contained in:
parent
64c9d71941
commit
9feb88d81a
@ -345,6 +345,8 @@ pub async fn thread_system(mut app:App, bus:Bus<protocol::QRPacket>)
|
||||
} {
|
||||
// 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) {
|
||||
|
@ -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<u8>
|
||||
{
|
||||
let handle_bytes = self.handle.as_bytes().to_vec();
|
||||
[
|
||||
pack_u16(self.status),
|
||||
pack_u8(handle_bytes.len() as u8),
|
||||
handle_bytes,
|
||||
].concat()
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user