aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sockets.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sockets.js b/lib/sockets.js
index fc9ab87f..e5816edd 100644
--- a/lib/sockets.js
+++ b/lib/sockets.js
@@ -60,9 +60,11 @@ wss.on("connection", function (ws, req) {
switch (type) {
case "login":
let token = data;
- if (!token || token === "null") return;
try {
+ if (!token || token === "null") throw new Error("Unauthorized socket login");
const username = jwt.decode(token).username;
+ if (!username) throw new Error("Invalid JWT token");
+
if (!sockets[username]) sockets[username] = {};
const existing = Object.keys(sockets[username]);
if (existing.length > 5) {