+ New user event

This commit is contained in:
Bryan Ashby 2018-06-03 19:58:05 -06:00
parent 0ae9d0d143
commit fbe87640c5
2 changed files with 14 additions and 3 deletions

View File

@ -2,13 +2,19 @@
'use strict'; 'use strict';
module.exports = { module.exports = {
ClientConnected : 'codes.l33t.enigma.system.connected', // { client, connectionCount } ClientConnected : 'codes.l33t.enigma.system.connected', // { client, connectionCount }
ClientDisconnected : 'codes.l33t.enigma.system.disconnected', // { client, connectionCount } ClientDisconnected : 'codes.l33t.enigma.system.disconnected', // { client, connectionCount }
TermDetected : 'codes.l33t.enigma.system.term_detected', // { client } TermDetected : 'codes.l33t.enigma.system.term_detected', // { client }
// User - includes { user, ...} // User - includes { user, ...}
NewUser : 'codes.l33t.enigma.system.new_user',
UserLogin : 'codes.l33t.enigma.system.user_login', UserLogin : 'codes.l33t.enigma.system.user_login',
UserLogoff : 'codes.l33t.enigma.system.user_logoff', UserLogoff : 'codes.l33t.enigma.system.user_logoff',
UserUpload : 'codes.l33t.enigma.system.user_upload', // {..., files[ fileEntry, ...] } UserUpload : 'codes.l33t.enigma.system.user_upload', // {..., files[ fileEntry, ...] }
UserDownload : 'codes.l33t.enigma.system.user_download', // {..., files[ fileEntry, ...] } UserDownload : 'codes.l33t.enigma.system.user_download', // {..., files[ fileEntry, ...] }
// NYI below here:
UserPostMessage : 'codes.l33t.enigma.system.user_post_msg',
UserSendMail : 'codes.l33t.enigma.system.user_send_mail',
UserSendRunDoor : 'codes.l33t.enigma.system.user_run_door',
}; };

View File

@ -5,6 +5,7 @@ const userDb = require('./database.js').dbs.user;
const Config = require('./config.js').config; const Config = require('./config.js').config;
const userGroup = require('./user_group.js'); const userGroup = require('./user_group.js');
const Errors = require('./enig_error.js').Errors; const Errors = require('./enig_error.js').Errors;
const Events = require('./events.js');
// deps // deps
const crypto = require('crypto'); const crypto = require('crypto');
@ -240,6 +241,10 @@ module.exports = class User {
self.persistWithTransaction(trans, err => { self.persistWithTransaction(trans, err => {
return callback(err, trans); return callback(err, trans);
}); });
},
function sendEvent(trans, callback) {
Events.emit(Events.getSystemEvents().NewUser, { user : self });
return callback(null, trans);
} }
], ],
(err, trans) => { (err, trans) => {