mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-11 23:24:43 +02:00
* Add FileBaseFilters
* Add HTTP(S) file web server with temp URLs * Get temp web d/l from file list * Add File area filter editor (all file area stuff will be rename to file "base" later) * Concept of "listening servers" vs "login servers" * Ability to get servers by their package name * New MCI: %FN: File Base active filter name * Some ES6 updates * VC resetInitialFocus() to set focus to explicit/detected initial focus field * Limit what is dumped out when logging form data
This commit is contained in:
parent
712cf512f0
commit
a7c0f2b7b0
22 changed files with 1233 additions and 286 deletions
|
@ -4,7 +4,6 @@
|
|||
// ENiGMA½
|
||||
const setClientTheme = require('./theme.js').setClientTheme;
|
||||
const clientConnections = require('./client_connections.js').clientConnections;
|
||||
const userDb = require('./database.js').dbs.user;
|
||||
const StatLog = require('./stat_log.js');
|
||||
const logger = require('./logger.js');
|
||||
|
||||
|
@ -21,66 +20,64 @@ function userLogin(client, username, password, cb) {
|
|||
// :TODO: if username exists, record failed login attempt to properties
|
||||
// :TODO: check Config max failed logon attempts/etc. - set err.maxAttempts = true
|
||||
|
||||
cb(err);
|
||||
} else {
|
||||
const now = new Date();
|
||||
const user = client.user;
|
||||
|
||||
//
|
||||
// Ensure this user is not already logged in.
|
||||
// Loop through active connections -- which includes the current --
|
||||
// and check for matching user ID. If the count is > 1, disallow.
|
||||
//
|
||||
var existingClientConnection;
|
||||
clientConnections.forEach(function connEntry(cc) {
|
||||
if(cc.user !== user && cc.user.userId === user.userId) {
|
||||
existingClientConnection = cc;
|
||||
}
|
||||
});
|
||||
|
||||
if(existingClientConnection) {
|
||||
client.log.info( {
|
||||
existingClientId : existingClientConnection.session.id,
|
||||
username : user.username,
|
||||
userId : user.userId },
|
||||
'Already logged in'
|
||||
);
|
||||
|
||||
var existingConnError = new Error('Already logged in as supplied user');
|
||||
existingConnError.existingConn = true;
|
||||
|
||||
return cb(existingClientConnection);
|
||||
}
|
||||
|
||||
|
||||
// update client logger with addition of username
|
||||
client.log = logger.log.child( { clientId : client.log.fields.clientId, username : user.username });
|
||||
client.log.info('Successful login');
|
||||
|
||||
async.parallel(
|
||||
[
|
||||
function setTheme(callback) {
|
||||
setClientTheme(client, user.properties.theme_id);
|
||||
callback(null);
|
||||
},
|
||||
function updateSystemLoginCount(callback) {
|
||||
StatLog.incrementSystemStat('login_count', 1, callback);
|
||||
},
|
||||
function recordLastLogin(callback) {
|
||||
StatLog.setUserStat(user, 'last_login_timestamp', StatLog.now, callback);
|
||||
},
|
||||
function updateUserLoginCount(callback) {
|
||||
StatLog.incrementUserStat(user, 'login_count', 1, callback);
|
||||
},
|
||||
function recordLoginHistory(callback) {
|
||||
const LOGIN_HISTORY_MAX = 200; // history of up to last 200 callers
|
||||
StatLog.appendSystemLogEntry('user_login_history', user.userId, LOGIN_HISTORY_MAX, StatLog.KeepType.Max, callback);
|
||||
}
|
||||
],
|
||||
function complete(err) {
|
||||
cb(err);
|
||||
}
|
||||
);
|
||||
return cb(err);
|
||||
}
|
||||
const user = client.user;
|
||||
|
||||
//
|
||||
// Ensure this user is not already logged in.
|
||||
// Loop through active connections -- which includes the current --
|
||||
// and check for matching user ID. If the count is > 1, disallow.
|
||||
//
|
||||
let existingClientConnection =
|
||||
clientConnections.forEach(function connEntry(cc) {
|
||||
if(cc.user !== user && cc.user.userId === user.userId) {
|
||||
existingClientConnection = cc;
|
||||
}
|
||||
});
|
||||
|
||||
if(existingClientConnection) {
|
||||
client.log.info( {
|
||||
existingClientId : existingClientConnection.session.id,
|
||||
username : user.username,
|
||||
userId : user.userId },
|
||||
'Already logged in'
|
||||
);
|
||||
|
||||
var existingConnError = new Error('Already logged in as supplied user');
|
||||
existingConnError.existingConn = true;
|
||||
|
||||
return cb(existingClientConnection);
|
||||
}
|
||||
|
||||
|
||||
// update client logger with addition of username
|
||||
client.log = logger.log.child( { clientId : client.log.fields.clientId, username : user.username });
|
||||
client.log.info('Successful login');
|
||||
|
||||
async.parallel(
|
||||
[
|
||||
function setTheme(callback) {
|
||||
setClientTheme(client, user.properties.theme_id);
|
||||
callback(null);
|
||||
},
|
||||
function updateSystemLoginCount(callback) {
|
||||
StatLog.incrementSystemStat('login_count', 1, callback);
|
||||
},
|
||||
function recordLastLogin(callback) {
|
||||
StatLog.setUserStat(user, 'last_login_timestamp', StatLog.now, callback);
|
||||
},
|
||||
function updateUserLoginCount(callback) {
|
||||
StatLog.incrementUserStat(user, 'login_count', 1, callback);
|
||||
},
|
||||
function recordLoginHistory(callback) {
|
||||
const LOGIN_HISTORY_MAX = 200; // history of up to last 200 callers
|
||||
StatLog.appendSystemLogEntry('user_login_history', user.userId, LOGIN_HISTORY_MAX, StatLog.KeepType.Max, callback);
|
||||
}
|
||||
],
|
||||
function complete(err) {
|
||||
cb(err);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue