* Last callers module WIP
This commit is contained in:
@@ -29,49 +29,52 @@ function MCIViewFactory(client) {
|
||||
}
|
||||
|
||||
MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
|
||||
return {
|
||||
BN : Config.general.boardName,
|
||||
VL : 'ENiGMA½ v' + packageJson.version,
|
||||
VN : packageJson.version,
|
||||
try {
|
||||
return {
|
||||
BN : Config.general.boardName,
|
||||
VL : 'ENiGMA½ v' + packageJson.version,
|
||||
VN : packageJson.version,
|
||||
|
||||
UN : this.client.user.username,
|
||||
UI : this.client.user.userId.toString(),
|
||||
UG : _.values(this.client.user.groups).join(', '),
|
||||
UR : this.client.user.properties.real_name,
|
||||
LO : this.client.user.properties.location,
|
||||
UA : this.client.user.getAge().toString(),
|
||||
UB : moment(this.client.user.properties.birthdate).format(this.client.currentTheme.helpers.getDateFormat()),
|
||||
US : this.client.user.properties.sex,
|
||||
UE : this.client.user.properties.email_address,
|
||||
UW : this.client.user.properties.web_address,
|
||||
UF : this.client.user.properties.affiliation,
|
||||
UT : this.client.user.properties.theme_id,
|
||||
MS : moment(this.client.user.properties.timestamp).format(this.client.currentTheme.helpers.getDateFormat()),
|
||||
UN : this.client.user.username,
|
||||
UI : this.client.user.userId.toString(),
|
||||
UG : _.values(this.client.user.groups).join(', '),
|
||||
UR : this.client.user.properties.real_name,
|
||||
LO : this.client.user.properties.location,
|
||||
UA : this.client.user.getAge().toString(),
|
||||
UB : moment(this.client.user.properties.birthdate).format(this.client.currentTheme.helpers.getDateFormat()),
|
||||
US : this.client.user.properties.sex,
|
||||
UE : this.client.user.properties.email_address,
|
||||
UW : this.client.user.properties.web_address,
|
||||
UF : this.client.user.properties.affiliation,
|
||||
UT : this.client.user.properties.theme_id,
|
||||
MS : moment(this.client.user.properties.timestamp).format(this.client.currentTheme.helpers.getDateFormat()),
|
||||
|
||||
|
||||
SH : this.client.term.termHeight.toString(),
|
||||
SW : this.client.term.termWidth.toString(),
|
||||
SH : this.client.term.termHeight.toString(),
|
||||
SW : this.client.term.termWidth.toString(),
|
||||
|
||||
ND : this.client.runtime.id.toString(),
|
||||
ND : this.client.runtime.id.toString(),
|
||||
|
||||
// :TODO: change to CD for 'Current Date'
|
||||
DT : moment().format(this.client.currentTheme.helpers.getDateFormat()),
|
||||
CT : moment().format(this.client.currentTheme.helpers.getTimeFormat()),
|
||||
// :TODO: change to CD for 'Current Date'
|
||||
DT : moment().format(this.client.currentTheme.helpers.getDateFormat()),
|
||||
CT : moment().format(this.client.currentTheme.helpers.getTimeFormat()),
|
||||
|
||||
|
||||
OS : {
|
||||
linux : 'Linux',
|
||||
darwin : 'Mac OS X',
|
||||
win32 : 'Windows',
|
||||
sunos : 'SunOS',
|
||||
freebsd : 'FreeBSD',
|
||||
}[os.platform()] || os.type(),
|
||||
OS : {
|
||||
linux : 'Linux',
|
||||
darwin : 'Mac OS X',
|
||||
win32 : 'Windows',
|
||||
sunos : 'SunOS',
|
||||
freebsd : 'FreeBSD',
|
||||
}[os.platform()] || os.type(),
|
||||
|
||||
OA : os.arch(),
|
||||
SC : os.cpus()[0].model,
|
||||
OA : os.arch(),
|
||||
SC : os.cpus()[0].model,
|
||||
|
||||
IP : this.client.address().address,
|
||||
}[code];
|
||||
IP : this.client.address().address,
|
||||
}[code];
|
||||
} catch(e) {
|
||||
}
|
||||
};
|
||||
|
||||
MCIViewFactory.prototype.createFromMCI = function(mci) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
'use strict';
|
||||
|
||||
var theme = require('../core/theme.js');
|
||||
var Log = require('../core/logger.js').log;
|
||||
//var Log = require('../core/logger.js').log;
|
||||
var ansi = require('../core/ansi_term.js');
|
||||
|
||||
var async = require('async');
|
||||
@@ -15,12 +15,12 @@ function login(callingMenu, formData, extraArgs) {
|
||||
|
||||
client.user.authenticate(formData.value.username, formData.value.password, function authenticated(err) {
|
||||
if(err) {
|
||||
Log.info( { username : formData.value.username }, 'Failed login attempt %s', err);
|
||||
client.log.info( { username : formData.value.username }, 'Failed login attempt %s', err);
|
||||
|
||||
client.gotoMenuModule( { name : callingMenu.menuConfig.fallback } );
|
||||
} else {
|
||||
// use client.user so we can get correct case
|
||||
Log.info( { username : callingMenu.client.user.username }, 'Successful login');
|
||||
client.log.info( { username : callingMenu.client.user.username }, 'Successful login');
|
||||
|
||||
async.parallel(
|
||||
[
|
||||
@@ -29,9 +29,18 @@ function login(callingMenu, formData, extraArgs) {
|
||||
client.currentTheme = theme;
|
||||
callback(null); // always non-fatal
|
||||
});
|
||||
},
|
||||
function recordLogin(callback) {
|
||||
client.user.persistProperty('last_login_timestamp', new Date().toISOString(), function persisted(err) {
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
],
|
||||
function complete(err, results) {
|
||||
if(err) {
|
||||
client.log.error(err);
|
||||
// :TODO: drop the connection?
|
||||
}
|
||||
client.gotoMenuModule( { name : callingMenu.menuConfig.next } );
|
||||
}
|
||||
);
|
||||
|
||||
@@ -208,8 +208,6 @@ function displayThemedPause(options, cb) {
|
||||
}
|
||||
|
||||
// :TODO: Support animated pause prompts. Probably via MCI with AnimatedView
|
||||
// :TODO: support prompts with a height > 1
|
||||
// :TODO: Prompt should support MCI codes in general
|
||||
|
||||
var artInfo;
|
||||
var vc;
|
||||
|
||||
12
core/user.js
12
core/user.js
@@ -296,6 +296,18 @@ User.prototype.persist = function(useTransaction, cb) {
|
||||
);
|
||||
};
|
||||
|
||||
User.prototype.persistProperty = function(propName, propValue, cb) {
|
||||
// update live props
|
||||
this.properties[propName] = propValue;
|
||||
|
||||
userDb.run(
|
||||
'REPLACE INTO user_property (user_id, prop_name, prop_value) ' +
|
||||
'VALUES (?, ?, ?);', [ this.userId, propName, propValue ], function ran(err) {
|
||||
cb(err);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
User.prototype.persistProperties = function(cb) {
|
||||
assert(this.userId > 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user