From 0ae9d0d1434797bcb0922f16cab97efcfb52b3fc Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sun, 3 Jun 2018 17:59:16 -0600 Subject: [PATCH] + User login and logoff events --- core/client_connections.js | 4 ++++ core/user.js | 3 ++- core/user_login.js | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/client_connections.js b/core/client_connections.js index 176b027a..121ea0fa 100644 --- a/core/client_connections.js +++ b/core/client_connections.js @@ -100,6 +100,10 @@ function removeClient(client) { 'Client disconnected' ); + if(client.user && client.user.isValid()) { + Events.emit(Events.getSystemEvents().UserLogoff, { user : client.user } ); + } + Events.emit( Events.getSystemEvents().ClientDisconnected, { client : client, connectionCount : clientConnections.length } diff --git a/core/user.js b/core/user.js index 59f150bb..16f84e8b 100644 --- a/core/user.js +++ b/core/user.js @@ -67,7 +67,8 @@ module.exports = class User { return false; } - return this.properties.pw_pbkdf2_salt.length === User.PBKDF2.saltLen * 2 && this.prop_name.pw_pbkdf2_dk.length === User.PBKDF2.keyLen * 2; + return ((this.properties.pw_pbkdf2_salt.length === User.PBKDF2.saltLen * 2) && + (this.properties.pw_pbkdf2_dk.length === User.PBKDF2.keyLen * 2)); } isRoot() { diff --git a/core/user_login.js b/core/user_login.js index 37c3b306..8e0e7404 100644 --- a/core/user_login.js +++ b/core/user_login.js @@ -6,6 +6,7 @@ const setClientTheme = require('./theme.js').setClientTheme; const clientConnections = require('./client_connections.js').clientConnections; const StatLog = require('./stat_log.js'); const logger = require('./logger.js'); +const Events = require('./events.js'); // deps const async = require('async'); @@ -59,6 +60,8 @@ function userLogin(client, username, password, cb) { client.log = logger.log.child( { clientId : client.log.fields.clientId, username : user.username }); client.log.info('Successful login'); + Events.emit(Events.getSystemEvents().UserLogin, { user } ); + async.parallel( [ function setTheme(callback) {