aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sockets.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-01-11 22:09:48 -0800
committerAdam Soltys <[email protected]>2023-01-12 15:44:13 -0800
commitc3565838644123e77881ff4f8536792f074047b9 (patch)
tree96da43fd19940d2f0836e43a511f0a1fb365044d /lib/sockets.js
parentded2c69ce89438326523a512b570be6eee4b23f0 (diff)
downloadcoinos-server-c3565838644123e77881ff4f8536792f074047b9.tar.gz
coinos-server-c3565838644123e77881ff4f8536792f074047b9.zip
migrating to redis
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" }));