From 8a554b6d3085efc3e4b062bdb0ac61cc0ce89416 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 8 Jul 2021 15:14:57 -0400 Subject: check that token can decode properly --- lib/sockets.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sockets.js b/lib/sockets.js index 931a9d23..bd59ee38 100644 --- a/lib/sockets.js +++ b/lib/sockets.js @@ -96,7 +96,7 @@ wss.on("connection", function(ws, req) { lastSeen[token] = new Date(); try { - if (!token || token === "null") return ws.close(); + if (!token || token === "null" || !jwt.decode(token)) return ws.close(); const username = jwt.decode(token).username; if (!username) throw new Error("Invalid JWT token"); -- cgit v1.2.3