From e68adbc7f56038ce234c72d055f3b6ddc878a779 Mon Sep 17 00:00:00 2001 From: axbuglak <alexeybuglak24@gmail.com> Date: Thu, 15 Feb 2024 23:15:40 +0100 Subject: [PATCH] initial --- lib/server.js | 9 +++++++++ lib/transport.js | 6 ------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/server.js b/lib/server.js index 1c5fbd77..e6989be8 100644 --- a/lib/server.js +++ b/lib/server.js @@ -188,6 +188,15 @@ class Server { const client = new Client(transport); const data = await metautil.receiveBody(req).catch(() => null); + const { token } = transport.getCookies(); + if (token) { + const restored = client.restoreSession(token); + if (!restored) { + const data = this.application.auth.readSession(token); + if (data) client.initializeSession(token, data); + } + } + if (req.url === '/api') { if (req.method !== 'POST') transport.error(403); else this.message(client, data); diff --git a/lib/transport.js b/lib/transport.js index a5cacfba..d63b6c57 100644 --- a/lib/transport.js +++ b/lib/transport.js @@ -177,12 +177,6 @@ class HttpTransport extends Transport { const { cookie } = this.req.headers; if (!cookie) return {}; return metautil.parseCookies(cookie); - /*const { token } = cookies.token; - if (!token) return; - const restored = client.restoreSession(token); - if (restored) return; - const data = await this.server.auth.readSession(token); - if (data) client.initializeSession(token, data);*/ } sendSessionCookie(token) {