add ban expires time to config file, it can be auto moved when the time is expires

This commit is contained in:
OldHawk
2017-05-12 16:55:30 +08:00
parent b74fddb162
commit 6c68b74367
3 changed files with 2 additions and 11 deletions

View File

@@ -77,7 +77,7 @@ module.exports = {
},
chat: {
ban: {
expires: 60 * 60 * 1000 * 2
expires: 60 * 60 * 1000 * 1
}
},
tmdbConfig: {

View File

@@ -99,19 +99,14 @@ module.exports = function (app, db) {
passport.session()(socket.request, {}, function () {
if (socket.request.user) {
// check ban list
//console.log(io.banClients);
var banned = false;
for (var i = io.banClients.length - 1; i >= 0; i--) {
var buser = io.banClients[i];
//console.log('buser.expires=' + buser.expires);
//console.log('Date.now()=' + Date.now());
if (buser.expires <= Date.now()) { //already expires, remove it
io.banClients.splice(io.banClients.indexOf(buser), 1);
continue;
} else {
var address = socket.handshake.address;
console.log(address);
console.log(buser.ip);
if (buser.user.username === socket.request.user.username) { //username in ban list
banned = true;
next(new Error('username "' + buser.user.username + '" is banned from the server'), false);

View File

@@ -64,10 +64,7 @@
// Make sure the Socket is connected
if (!Socket.socket) {
Socket.connect(function (err) {
console.log('========server error===========');
console.log(err);
});
Socket.connect();
}
// Remove the event listener when the controller instance is destroyed
@@ -308,7 +305,6 @@
* @param uitem
*/
vm.onUserListItemDblClicked = function (uitem) {
console.log(uitem);
addAtUserToInput(' [@' + uitem.displayName + '] ');
};