aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sockets.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sockets.js')
-rw-r--r--lib/sockets.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/sockets.js b/lib/sockets.js
index 1ed18610..25f8aed8 100644
--- a/lib/sockets.js
+++ b/lib/sockets.js
@@ -106,6 +106,7 @@ wss.on("connection", function(ws, req) {
names[id] = username;
let user = await getUser(username);
+ if (user.locked) throw new Error("Account is locked");
let payments = await user.getPayments({
where: {
account_id: user.account_id
@@ -131,9 +132,13 @@ wss.on("connection", function(ws, req) {
);
} catch (e) {
l.error("caught socket error", e.message);
+ if (e.message.includes("locked")) {
+ ws.send(JSON.stringify({ type: "locked" }));
+ ws.send(JSON.stringify({ type: "logout" }));
+ }
if (e.message.includes("not found"))
ws.send(JSON.stringify({ type: "logout" }));
- setTimeout(ws.close, 1000);
+ setTimeout(() => ws && ws.close(), 1000);
}
break;
case "token":