From 8076c6c8da495331a6013671f80f178e57d42d19 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 6 Jan 2023 22:10:54 +0000 Subject: still encode username in token --- lib/sockets.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/sockets.js') diff --git a/lib/sockets.js b/lib/sockets.js index 7498db62..3bd0c2c2 100644 --- a/lib/sockets.js +++ b/lib/sockets.js @@ -92,8 +92,8 @@ app.register(async function(app) { try { if (!token || token === "null" || !jwt.decode(token)) return ws.close(code, `bad token ${token}`); - const username = jwt.decode(token).username; - if (!username) throw new Error("Invalid JWT token"); + const { username, uuid } = jwt.decode(token); + if (!(username || uuid)) throw new Error("Invalid JWT token"); if (!store.sockets[username]) store.sockets[username] = {}; const existing = Object.keys(store.sockets[username]); -- cgit v1.2.3