aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sockets.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sockets.js')
-rw-r--r--lib/sockets.js12
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/sockets.js b/lib/sockets.js
index ecf15dd7..0f343937 100644
--- a/lib/sockets.js
+++ b/lib/sockets.js
@@ -91,8 +91,10 @@ app.register(async function(app) {
try {
if (!token || token === "null" || !jwt.decode(token))
return ws.close(code, `bad token ${token}`);
+
let { uuid } = jwt.decode(token);
if (!uuid) throw new Error("Invalid JWT token");
+ console.log("UUID", uuid)
let user = await getUser(uuid);
if (!user) throw new Error("User not found");
@@ -109,15 +111,6 @@ app.register(async function(app) {
store.sockets[uuid][id] = ws;
names[id] = uuid;
- let { haspin } = user;
-
- let keys = await user.getKeys();
- user = user.get({ plain: true });
- user.accounts = accounts;
- user.keys = keys;
- user.payments = payments;
- user.haspin = haspin;
-
ws.user = user;
ws.send(
JSON.stringify({ type: "login", data: pick(user, ...whitelist) })
@@ -126,6 +119,7 @@ app.register(async function(app) {
JSON.stringify({ type: "version", data: config.clientVersion })
);
} catch (e) {
+ console.log(e)
err("caught socket error", e.message);
if (e.message.includes("not found"))
ws.send(JSON.stringify({ type: "logout" }));