From c4314c2678b852234975d1babbbe49fcf851083c Mon Sep 17 00:00:00 2001 From: flifloo Date: Mon, 2 Nov 2020 17:22:50 +0100 Subject: [PATCH] Secure sockets listener for login or not login user --- sockets/index.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sockets/index.js b/sockets/index.js index 2618813..ff1a0c6 100644 --- a/sockets/index.js +++ b/sockets/index.js @@ -1,10 +1,13 @@ module.exports = socket => { console.log("New connection !"); - socket.on("login", require("./login")(socket)); - socket.on("register", require("./register")(socket)); - socket.on("checkResend", require("./email/checkResend")(socket)); - socket.on("forgotPassword", require("./email/forgotPassword")(socket)); - socket.on("setPassword", require("./email/setPassword")(socket)); - socket.on("profileEdit", require("./profile/edit")(socket)); + if (!socket.request.session.user) { + socket.on("login", require("./login")(socket)); + socket.on("register", require("./register")(socket)); + socket.on("checkResend", require("./email/checkResend")(socket)); + socket.on("forgotPassword", require("./email/forgotPassword")(socket)); + socket.on("setPassword", require("./email/setPassword")(socket)); + } else { + socket.on("profileEdit", require("./profile/edit")(socket)); + } socket.emit("connected"); }