Browse Source

fix: fixed issue with punishments module failing and punishments not working well

Kristian Vos 5 years ago
parent
commit
de529b67f9
2 changed files with 4 additions and 4 deletions
  1. 3 3
      backend/logic/io.js
  2. 1 1
      backend/logic/punishments.js

+ 3 - 3
backend/logic/io.js

@@ -82,7 +82,7 @@ module.exports = class extends coreClass {
 								if (punishment.type === 'banUserIp' && punishment.value === socket.ip) banishment.banned = true;
 							});
 							
-							socket = { ...socket, ...banishment }
+							socket.banishment = banishment;
 
 							next();
 						});
@@ -103,9 +103,9 @@ module.exports = class extends coreClass {
 				if (socket.session.sessionId) sessionInfo = ` UserID: ${socket.session.userId}.`;
 
 				// if session is banned
-				if (socket.banned) {
+				if (socket.banishment.banned) {
 					logger.info('IO_BANNED_CONNECTION', `A user tried to connect, but is currently banned. IP: ${socket.ip}.${sessionInfo}`);
-					socket.emit('keep.event:banned', socket.ban);
+					socket.emit('keep.event:banned', socket.banishment.ban);
 					socket.disconnect(true);
 				} else {
 					logger.info('IO_CONNECTION', `User connected. IP: ${socket.ip}.${sessionInfo}`);

+ 1 - 1
backend/logic/punishments.js

@@ -49,7 +49,7 @@ module.exports = class extends coreClass {
 					this.setStage(5);
 					async.each(punishments, (punishment, next) => {
 						if (punishment.active === false || punishment.expiresAt < Date.now()) return next();
-						this.cache.hset('punishments', punishment._id, cache.schemas.punishment(punishment, punishment._id), next);
+						this.cache.hset('punishments', punishment._id, this.cache.schemas.punishment(punishment, punishment._id), next);
 					}, next);
 				}
 			], async (err) => {