More conversion to UserProps
This commit is contained in:
parent
b82c640014
commit
4050affedf
|
@ -2,13 +2,14 @@
|
|||
'use strict';
|
||||
|
||||
// ENiGMA½
|
||||
const logger = require('./logger.js');
|
||||
const Events = require('./events.js');
|
||||
const logger = require('./logger.js');
|
||||
const Events = require('./events.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const _ = require('lodash');
|
||||
const moment = require('moment');
|
||||
const hashids = require('hashids');
|
||||
const _ = require('lodash');
|
||||
const moment = require('moment');
|
||||
const hashids = require('hashids');
|
||||
|
||||
exports.getActiveConnections = getActiveConnections;
|
||||
exports.getActiveNodeList = getActiveNodeList;
|
||||
|
@ -17,7 +18,7 @@ exports.removeClient = removeClient;
|
|||
exports.getConnectionByUserId = getConnectionByUserId;
|
||||
|
||||
const clientConnections = [];
|
||||
exports.clientConnections = clientConnections;
|
||||
exports.clientConnections = clientConnections;
|
||||
|
||||
function getActiveConnections() { return clientConnections; }
|
||||
|
||||
|
@ -46,11 +47,11 @@ function getActiveNodeList(authUsersOnly) {
|
|||
//
|
||||
if(ac.user.isAuthenticated()) {
|
||||
entry.userName = ac.user.username;
|
||||
entry.realName = ac.user.properties.real_name;
|
||||
entry.location = ac.user.properties.location;
|
||||
entry.affils = entry.affiliation = ac.user.properties.affiliation;
|
||||
entry.realName = ac.user.properties[UserProps.RealName];
|
||||
entry.location = ac.user.properties[UserProps.Location];
|
||||
entry.affils = entry.affiliation = ac.user.properties[UserProps.Affiliations];
|
||||
|
||||
const diff = now.diff(moment(ac.user.properties.last_login_timestamp), 'minutes');
|
||||
const diff = now.diff(moment(ac.user.properties[UserProps.LastLoginTs]), 'minutes');
|
||||
entry.timeOn = moment.duration(diff, 'minutes');
|
||||
}
|
||||
return entry;
|
||||
|
@ -61,7 +62,7 @@ function addNewClient(client, clientSock) {
|
|||
const id = client.session.id = clientConnections.push(client) - 1;
|
||||
const remoteAddress = client.remoteAddress = clientSock.remoteAddress;
|
||||
|
||||
// create a uniqe identifier one-time ID for this session
|
||||
// create a unique identifier one-time ID for this session
|
||||
client.session.uniqueId = new hashids('ENiGMA½ClientSession').encode([ id, moment().valueOf() ]);
|
||||
|
||||
// Create a client specific logger
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
'use strict';
|
||||
|
||||
const FileEntry = require('./file_entry.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const { partition } = require('lodash');
|
||||
|
@ -11,8 +12,8 @@ module.exports = class DownloadQueue {
|
|||
this.client = client;
|
||||
|
||||
if(!Array.isArray(this.client.user.downloadQueue)) {
|
||||
if(this.client.user.properties.dl_queue) {
|
||||
this.loadFromProperty(this.client.user.properties.dl_queue);
|
||||
if(this.client.user.properties[UserProps.DownloadQueue]) {
|
||||
this.loadFromProperty(this.client.user.properties[UserProps.DownloadQueue]);
|
||||
} else {
|
||||
this.client.user.downloadQueue = [];
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
// ENiGMA½
|
||||
const Config = require('./config.js').get;
|
||||
const StatLog = require('./stat_log.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const fs = require('graceful-fs');
|
||||
|
@ -168,7 +169,7 @@ module.exports = class DropFile {
|
|||
'115200',
|
||||
Config().general.boardName,
|
||||
this.client.user.userId.toString(),
|
||||
this.client.user.properties.real_name || this.client.user.username,
|
||||
this.client.user.properties[UserProps.RealName] || this.client.user.username,
|
||||
this.client.user.username,
|
||||
this.client.user.getLegacySecurityLevel().toString(),
|
||||
'546', // :TODO: Minutes left!
|
||||
|
@ -189,21 +190,22 @@ module.exports = class DropFile {
|
|||
const opUserName = /[^\s]*/.exec(StatLog.getSystemStat('sysop_username'))[0];
|
||||
const userName = /[^\s]*/.exec(this.client.user.username)[0];
|
||||
const secLevel = this.client.user.getLegacySecurityLevel().toString();
|
||||
const location = this.client.user.properties[UserProps.Location];
|
||||
|
||||
return iconv.encode( [
|
||||
Config().general.boardName, // "The name of the system."
|
||||
opUserName, // "The sysop's name up to the first space."
|
||||
opUserName, // "The sysop's name following the first space."
|
||||
'COM1', // "The serial port the modem is connected to, or 0 if logged in on console."
|
||||
'57600', // "The current port (DTE) rate."
|
||||
'0', // "The number "0""
|
||||
userName, // "The current user's name, up to the first space."
|
||||
userName, // "The current user's name, following the first space."
|
||||
this.client.user.properties.location || '', // "Where the user lives, or a blank line if unknown."
|
||||
'1', // "The number "0" if TTY, or "1" if ANSI."
|
||||
secLevel, // "The number 5 for problem users, 30 for regular users, 80 for Aides, and 100 for Sysops."
|
||||
'546', // "The number of minutes left in the current user's account, limited to 546 to keep from overflowing other software."
|
||||
'-1' // "The number "-1" if using an external serial driver or "0" if using internal serial routines."
|
||||
Config().general.boardName, // "The name of the system."
|
||||
opUserName, // "The sysop's name up to the first space."
|
||||
opUserName, // "The sysop's name following the first space."
|
||||
'COM1', // "The serial port the modem is connected to, or 0 if logged in on console."
|
||||
'57600', // "The current port (DTE) rate."
|
||||
'0', // "The number "0""
|
||||
userName, // "The current user's name, up to the first space."
|
||||
userName, // "The current user's name, following the first space."
|
||||
location || '', // "Where the user lives, or a blank line if unknown."
|
||||
'1', // "The number "0" if TTY, or "1" if ANSI."
|
||||
secLevel, // "The number 5 for problem users, 30 for regular users, 80 for Aides, and 100 for Sysops."
|
||||
'546', // "The number of minutes left in the current user's account, limited to 546 to keep from overflowing other software."
|
||||
'-1' // "The number "-1" if using an external serial driver or "0" if using internal serial routines."
|
||||
].join('\r\n') + '\r\n', 'cp437');
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ const ViewController = require('./view_controller.js').ViewContro
|
|||
const getSortedAvailableFileAreas = require('./file_base_area.js').getSortedAvailableFileAreas;
|
||||
const FileBaseFilters = require('./file_base_filter.js');
|
||||
const stringFormat = require('./string_format.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
|
@ -111,7 +112,7 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule {
|
|||
//
|
||||
// If the item was also the active filter, we need to make a new one active
|
||||
//
|
||||
if(filterUuid === this.client.user.properties.file_base_filter_active_uuid) {
|
||||
if(filterUuid === this.client.user.properties[UserProps.FileBaseFilterActiveUuid]) {
|
||||
const newActive = this.filtersArray[this.currentFilterIndex];
|
||||
if(newActive) {
|
||||
filters.setActive(newActive.uuid);
|
||||
|
|
|
@ -66,7 +66,7 @@ module.exports = class FileBaseFilters {
|
|||
}
|
||||
|
||||
load() {
|
||||
let filtersProperty = this.client.user.properties.file_base_filters;
|
||||
let filtersProperty = this.client.user.properties[UserProps.FileBaseFilters];
|
||||
let defaulted;
|
||||
if(!filtersProperty) {
|
||||
filtersProperty = JSON.stringify(FileBaseFilters.getBuiltInSystemFilters());
|
||||
|
@ -131,11 +131,11 @@ module.exports = class FileBaseFilters {
|
|||
}
|
||||
|
||||
static getActiveFilter(client) {
|
||||
return new FileBaseFilters(client).get(client.user.properties.file_base_filter_active_uuid);
|
||||
return new FileBaseFilters(client).get(client.user.properties[UserProps.FileBaseFilterActiveUuid]);
|
||||
}
|
||||
|
||||
static getFileBaseLastViewedFileIdByUser(user) {
|
||||
return parseInt((user.properties.user_file_base_last_viewed || 0));
|
||||
return parseInt((user.properties[UserProps.FileBaseLastViewedId] || 0));
|
||||
}
|
||||
|
||||
static setFileBaseLastViewedFileIdForUser(user, fileId, allowOlder, cb) {
|
||||
|
|
|
@ -24,6 +24,7 @@ const {
|
|||
const Config = require('./config.js').get;
|
||||
const { getAddressedToInfo } = require('./mail_util.js');
|
||||
const Events = require('./events.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
|
@ -738,7 +739,7 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
|||
const fromView = self.viewControllers.header.getView(MciViewIds.header.from);
|
||||
const area = getMessageAreaByTag(self.messageAreaTag);
|
||||
if(area && area.realNames) {
|
||||
fromView.setText(self.client.user.properties.real_name || self.client.user.username);
|
||||
fromView.setText(self.client.user.properties[UserProps.RealName] || self.client.user.username);
|
||||
} else {
|
||||
fromView.setText(self.client.user.username);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ const conf = require('./config.js');
|
|||
const logger = require('./logger.js');
|
||||
const ServerModule = require('./server_module.js').ServerModule;
|
||||
const clientConns = require('./client_connections.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const _ = require('lodash');
|
||||
|
@ -25,12 +26,12 @@ module.exports = class LoginServerModule extends ServerModule {
|
|||
//
|
||||
const preLoginTheme = _.get(conf.config, 'theme.preLogin');
|
||||
if('*' === preLoginTheme) {
|
||||
client.user.properties.theme_id = theme.getRandomTheme() || '';
|
||||
client.user.properties[UserProps.ThemeId] = theme.getRandomTheme() || '';
|
||||
} else {
|
||||
client.user.properties.theme_id = preLoginTheme;
|
||||
client.user.properties[UserProps.ThemeId] = preLoginTheme;
|
||||
}
|
||||
|
||||
theme.setClientTheme(client, client.user.properties.theme_id);
|
||||
theme.setClientTheme(client, client.user.properties[UserProps.ThemeId]);
|
||||
return cb(null); // note: currently useless to use cb here - but this may change...again...
|
||||
}
|
||||
|
||||
|
|
|
@ -304,8 +304,8 @@ function tempChangeMessageConfAndArea(client, areaTag) {
|
|||
return false;
|
||||
}
|
||||
|
||||
client.user.properties.message_conf_tag = confTag;
|
||||
client.user.properties.message_area_tag = areaTag;
|
||||
client.user.properties[UserProps.MessageConfTag] = confTag;
|
||||
client.user.properties[UserProps.MessageAreaTag] = areaTag;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
'use strict';
|
||||
|
||||
const messageArea = require('../core/message_area.js');
|
||||
const { get } = require('lodash');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const { get } = require('lodash');
|
||||
|
||||
exports.MessageAreaConfTempSwitcher = Sup => class extends Sup {
|
||||
|
||||
|
@ -15,8 +17,8 @@ exports.MessageAreaConfTempSwitcher = Sup => class extends Sup {
|
|||
|
||||
if(recordPrevious) {
|
||||
this.prevMessageConfAndArea = {
|
||||
confTag : this.client.user.properties.message_conf_tag,
|
||||
areaTag : this.client.user.properties.message_area_tag,
|
||||
confTag : this.client.user.properties[UserProps.MessageConfTag],
|
||||
areaTag : this.client.user.properties[UserProps.MessageAreaTag],
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -27,8 +29,8 @@ exports.MessageAreaConfTempSwitcher = Sup => class extends Sup {
|
|||
|
||||
tempMessageConfAndAreaRestore() {
|
||||
if(this.prevMessageConfAndArea) {
|
||||
this.client.user.properties.message_conf_tag = this.prevMessageConfAndArea.confTag;
|
||||
this.client.user.properties.message_area_tag = this.prevMessageConfAndArea.areaTag;
|
||||
this.client.user.properties[UserProps.MessageConfTag] = this.prevMessageConfAndArea.confTag;
|
||||
this.client.user.properties[UserProps.MessageAreaTag] = this.prevMessageConfAndArea.areaTag;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
const { MenuModule } = require('./menu_module.js');
|
||||
const messageArea = require('./message_area.js');
|
||||
const { Errors } = require('./enig_error.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
|
@ -110,7 +111,7 @@ exports.getModule = class MessageAreaListModule extends MenuModule {
|
|||
initList() {
|
||||
let index = 1;
|
||||
this.messageAreas = messageArea.getSortedAvailMessageAreasByConfTag(
|
||||
this.client.user.properties.message_conf_tag,
|
||||
this.client.user.properties[UserProps.MessageConfTag],
|
||||
{ client : this.client }
|
||||
).map(area => {
|
||||
return {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
const FullScreenEditorModule = require('./fse.js').FullScreenEditorModule;
|
||||
const persistMessage = require('./message_area.js').persistMessage;
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
const _ = require('lodash');
|
||||
const async = require('async');
|
||||
|
@ -58,8 +59,10 @@ exports.getModule = class AreaPostFSEModule extends FullScreenEditorModule {
|
|||
}
|
||||
|
||||
enter() {
|
||||
if(_.isString(this.client.user.properties.message_area_tag) && !_.isString(this.messageAreaTag)) {
|
||||
this.messageAreaTag = this.client.user.properties.message_area_tag;
|
||||
if(_.isString(this.client.user.properties[UserProps.MessageAreaTag]) &&
|
||||
!_.isString(this.messageAreaTag))
|
||||
{
|
||||
this.messageAreaTag = this.client.user.properties[UserProps.MessageAreaTag];
|
||||
}
|
||||
|
||||
super.enter();
|
||||
|
|
|
@ -8,6 +8,7 @@ const messageArea = require('./message_area.js');
|
|||
const MessageAreaConfTempSwitcher = require('./mod_mixins.js').MessageAreaConfTempSwitcher;
|
||||
const Errors = require('./enig_error.js').Errors;
|
||||
const Message = require('./message.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
|
@ -167,7 +168,7 @@ exports.getModule = class MessageListModule extends MessageAreaConfTempSwitcher(
|
|||
if(this.config.messageAreaTag) {
|
||||
this.tempMessageConfAndAreaSwitch(this.config.messageAreaTag);
|
||||
} else {
|
||||
this.config.messageAreaTag = this.client.user.properties.message_area_tag;
|
||||
this.config.messageAreaTag = this.client.user.properties[UserProps.MessageAreaTag];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,17 +2,18 @@
|
|||
'use strict';
|
||||
|
||||
// ENiGMA½
|
||||
const Config = require('./config.js').get;
|
||||
const Log = require('./logger.js').log;
|
||||
const Config = require('./config.js').get;
|
||||
const Log = require('./logger.js').log;
|
||||
const {
|
||||
getMessageAreaByTag,
|
||||
getMessageConferenceByTag
|
||||
} = require('./message_area.js');
|
||||
const clientConnections = require('./client_connections.js');
|
||||
const StatLog = require('./stat_log.js');
|
||||
const FileBaseFilters = require('./file_base_filter.js');
|
||||
const { formatByteSize } = require('./string_util.js');
|
||||
const ANSI = require('./ansi_term.js');
|
||||
} = require('./message_area.js');
|
||||
const clientConnections = require('./client_connections.js');
|
||||
const StatLog = require('./stat_log.js');
|
||||
const FileBaseFilters = require('./file_base_filter.js');
|
||||
const { formatByteSize } = require('./string_util.js');
|
||||
const ANSI = require('./ansi_term.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const packageJson = require('../package.json');
|
||||
|
@ -83,7 +84,9 @@ const PREDEFINED_MCI_GENERATORS = {
|
|||
UR : function realName(client) { return userStatAsString(client, 'real_name', ''); },
|
||||
LO : function location(client) { return userStatAsString(client, 'location', ''); },
|
||||
UA : function age(client) { return client.user.getAge().toString(); },
|
||||
BD : function birthdate(client) { return moment(client.user.properties.birthdate).format(client.currentTheme.helpers.getDateFormat()); }, // iNiQUiTY
|
||||
BD : function birthdate(client) { // iNiQUiTY
|
||||
return moment(client.user.properties[UserProps.Birthdate]).format(client.currentTheme.helpers.getDateFormat());
|
||||
},
|
||||
US : function sex(client) { return userStatAsString(client, 'sex', ''); },
|
||||
UE : function emailAddres(client) { return userStatAsString(client, 'email_address', ''); },
|
||||
UW : function webAddress(client) { return userStatAsString(client, 'web_address', ''); },
|
||||
|
@ -114,7 +117,9 @@ const PREDEFINED_MCI_GENERATORS = {
|
|||
return getUserRatio(client, 'ul_total_bytes', 'dl_total_bytes');
|
||||
},
|
||||
|
||||
MS : function accountCreatedclient(client) { return moment(client.user.properties.account_created).format(client.currentTheme.helpers.getDateFormat()); },
|
||||
MS : function accountCreatedclient(client) {
|
||||
return moment(client.user.properties[UserProps.AccountCreated]).format(client.currentTheme.helpers.getDateFormat());
|
||||
},
|
||||
PS : function userPostCount(client) { return userStatAsString(client, 'post_count', 0); },
|
||||
PC : function userPostCallRatio(client) { return getUserRatio(client, 'post_count', 'login_count'); },
|
||||
|
||||
|
@ -123,19 +128,19 @@ const PREDEFINED_MCI_GENERATORS = {
|
|||
},
|
||||
|
||||
MA : function messageAreaName(client) {
|
||||
const area = getMessageAreaByTag(client.user.properties.message_area_tag);
|
||||
const area = getMessageAreaByTag(client.user.properties[UserProps.MessageAreaTag]);
|
||||
return area ? area.name : '';
|
||||
},
|
||||
MC : function messageConfName(client) {
|
||||
const conf = getMessageConferenceByTag(client.user.properties.message_conf_tag);
|
||||
const conf = getMessageConferenceByTag(client.user.properties[UserProps.MessageConfTag]);
|
||||
return conf ? conf.name : '';
|
||||
},
|
||||
ML : function messageAreaDescription(client) {
|
||||
const area = getMessageAreaByTag(client.user.properties.message_area_tag);
|
||||
const area = getMessageAreaByTag(client.user.properties[UserProps.MessageAreaTag]);
|
||||
return area ? area.desc : '';
|
||||
},
|
||||
CM : function messageConfDescription(client) {
|
||||
const conf = getMessageConferenceByTag(client.user.properties.message_conf_tag);
|
||||
const conf = getMessageConferenceByTag(client.user.properties[UserProps.MessageConfTag]);
|
||||
return conf ? conf.desc : '';
|
||||
},
|
||||
|
||||
|
@ -169,8 +174,9 @@ const PREDEFINED_MCI_GENERATORS = {
|
|||
// Clean up CPU strings a bit for better display
|
||||
//
|
||||
return os.cpus()[0].model
|
||||
.replace(/\(R\)|\(TM\)|processor|CPU/g, '')
|
||||
.replace(/\s+(?= )/g, '');
|
||||
.replace(/\(R\)|\(TM\)|processor|CPU/ig, '')
|
||||
.replace(/\s+(?= )/g, '')
|
||||
.trim();
|
||||
},
|
||||
|
||||
// :TODO: MCI for core count, e.g. os.cpus().length
|
||||
|
|
|
@ -14,7 +14,7 @@ const {
|
|||
updateMessageAreaLastReadId,
|
||||
getMessageIdNewerThanTimestampByArea
|
||||
} = require('./message_area.js');
|
||||
const stringFormat = require('./string_format.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
|
@ -183,8 +183,8 @@ exports.getModule = class SetNewScanDate extends MenuModule {
|
|||
});
|
||||
|
||||
// Find current conf/area & move it directly under "All"
|
||||
const currConfTag = this.client.user.properties.message_conf_tag;
|
||||
const currAreaTag = this.client.user.properties.message_area_tag;
|
||||
const currConfTag = this.client.user.properties[UserProps.MessageConfTag];
|
||||
const currAreaTag = this.client.user.properties[UserProps.MessageAreaTag];
|
||||
if(currConfTag && currAreaTag) {
|
||||
const confAreaIndex = selections.findIndex( confArea => {
|
||||
return confArea.conf.confTag === currConfTag && confArea.area.areaTag === currAreaTag;
|
||||
|
|
|
@ -7,6 +7,7 @@ const ansiNormal = require('./ansi_term.js').normal;
|
|||
const { userLogin } = require('./user_login.js');
|
||||
const messageArea = require('./message_area.js');
|
||||
const { ErrorReasons } = require('./enig_error.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const _ = require('lodash');
|
||||
|
@ -105,7 +106,7 @@ function reloadMenu(menu, cb) {
|
|||
|
||||
function prevConf(callingMenu, formData, extraArgs, cb) {
|
||||
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
||||
const currIndex = confs.findIndex( e => e.confTag === callingMenu.client.user.properties.message_conf_tag) || confs.length;
|
||||
const currIndex = confs.findIndex( e => e.confTag === callingMenu.client.user.properties[UserProps.MessageConfTag]) || confs.length;
|
||||
|
||||
messageArea.changeMessageConference(callingMenu.client, confs[currIndex - 1].confTag, err => {
|
||||
if(err) {
|
||||
|
@ -118,7 +119,7 @@ function prevConf(callingMenu, formData, extraArgs, cb) {
|
|||
|
||||
function nextConf(callingMenu, formData, extraArgs, cb) {
|
||||
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
||||
let currIndex = confs.findIndex( e => e.confTag === callingMenu.client.user.properties.message_conf_tag);
|
||||
let currIndex = confs.findIndex( e => e.confTag === callingMenu.client.user.properties[UserProps.MessageConfTag]);
|
||||
|
||||
if(currIndex === confs.length - 1) {
|
||||
currIndex = -1;
|
||||
|
@ -134,8 +135,8 @@ function nextConf(callingMenu, formData, extraArgs, cb) {
|
|||
}
|
||||
|
||||
function prevArea(callingMenu, formData, extraArgs, cb) {
|
||||
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
||||
const currIndex = areas.findIndex( e => e.areaTag === callingMenu.client.user.properties.message_area_tag) || areas.length;
|
||||
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties[UserProps.MessageConfTag]);
|
||||
const currIndex = areas.findIndex( e => e.areaTag === callingMenu.client.user.properties[UserProps.MessageAreaTag]) || areas.length;
|
||||
|
||||
messageArea.changeMessageArea(callingMenu.client, areas[currIndex - 1].areaTag, err => {
|
||||
if(err) {
|
||||
|
@ -147,8 +148,8 @@ function prevArea(callingMenu, formData, extraArgs, cb) {
|
|||
}
|
||||
|
||||
function nextArea(callingMenu, formData, extraArgs, cb) {
|
||||
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
||||
let currIndex = areas.findIndex( e => e.areaTag === callingMenu.client.user.properties.message_area_tag);
|
||||
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties[UserProps.MessageConfTag]);
|
||||
let currIndex = areas.findIndex( e => e.areaTag === callingMenu.client.user.properties[UserProps.MessageAreaTag]);
|
||||
|
||||
if(currIndex === areas.length - 1) {
|
||||
currIndex = -1;
|
||||
|
|
|
@ -13,7 +13,9 @@ const Errors = require('./enig_error.js').Errors;
|
|||
const ErrorReasons = require('./enig_error.js').ErrorReasons;
|
||||
const Events = require('./events.js');
|
||||
const AnsiPrep = require('./ansi_prep.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const fs = require('graceful-fs');
|
||||
const paths = require('path');
|
||||
const async = require('async');
|
||||
|
@ -427,8 +429,8 @@ function getThemeArt(options, cb) {
|
|||
// random
|
||||
//
|
||||
const config = Config();
|
||||
if(!options.themeId && _.has(options, 'client.user.properties.theme_id')) {
|
||||
options.themeId = options.client.user.properties.theme_id;
|
||||
if(!options.themeId && _.has(options, [ 'client', 'user', 'properties', UserProps.ThemeId ])) {
|
||||
options.themeId = options.client.user.properties[UserProps.ThemeId];
|
||||
} else {
|
||||
options.themeId = config.theme.default;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ exports.getModule = class UserConfigModule extends MenuModule {
|
|||
//
|
||||
// If nothing changed, we know it's OK
|
||||
//
|
||||
if(self.client.user.properties.email_address.toLowerCase() === data.toLowerCase()) {
|
||||
if(self.client.user.properties[UserProps.EmailAddress].toLowerCase() === data.toLowerCase()) {
|
||||
return cb(null);
|
||||
}
|
||||
|
||||
|
@ -182,22 +182,22 @@ exports.getModule = class UserConfigModule extends MenuModule {
|
|||
}), 'name');
|
||||
|
||||
currentThemeIdIndex = Math.max(0, _.findIndex(self.availThemeInfo, function cmp(ti) {
|
||||
return ti.themeId === self.client.user.properties.theme_id;
|
||||
return ti.themeId === self.client.user.properties[UserProps.ThemeId];
|
||||
}));
|
||||
|
||||
callback(null);
|
||||
},
|
||||
function populateViews(callback) {
|
||||
var user = self.client.user;
|
||||
const user = self.client.user;
|
||||
|
||||
self.setViewText('menu', MciCodeIds.RealName, user.properties.real_name);
|
||||
self.setViewText('menu', MciCodeIds.BirthDate, moment(user.properties.birthdate).format('YYYYMMDD'));
|
||||
self.setViewText('menu', MciCodeIds.Sex, user.properties.sex);
|
||||
self.setViewText('menu', MciCodeIds.Loc, user.properties.location);
|
||||
self.setViewText('menu', MciCodeIds.Affils, user.properties.affiliation);
|
||||
self.setViewText('menu', MciCodeIds.Email, user.properties.email_address);
|
||||
self.setViewText('menu', MciCodeIds.Web, user.properties.web_address);
|
||||
self.setViewText('menu', MciCodeIds.TermHeight, user.properties.term_height.toString());
|
||||
self.setViewText('menu', MciCodeIds.RealName, user.properties[UserProps.RealName]);
|
||||
self.setViewText('menu', MciCodeIds.BirthDate, moment(user.properties[UserProps.Birthdate]).format('YYYYMMDD'));
|
||||
self.setViewText('menu', MciCodeIds.Sex, user.properties[UserProps.Sex]);
|
||||
self.setViewText('menu', MciCodeIds.Loc, user.properties[UserProps.Location]);
|
||||
self.setViewText('menu', MciCodeIds.Affils, user.properties[UserProps.Affiliations]);
|
||||
self.setViewText('menu', MciCodeIds.Email, user.properties[UserProps.EmailAddress]);
|
||||
self.setViewText('menu', MciCodeIds.Web, user.properties[UserProps.WebAddress]);
|
||||
self.setViewText('menu', MciCodeIds.TermHeight, user.properties[UserProps.TermHeight].toString());
|
||||
|
||||
|
||||
var themeView = self.getView(MciCodeIds.Theme);
|
||||
|
|
|
@ -12,6 +12,7 @@ const {
|
|||
Errors,
|
||||
ErrorReasons
|
||||
} = require('./enig_error.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
|
@ -74,24 +75,24 @@ function userLogin(client, username, password, cb) {
|
|||
client.log.info('Successful login');
|
||||
|
||||
// User's unique session identifier is the same as the connection itself
|
||||
user.sessionId = client.session.uniqueId; // convienence
|
||||
user.sessionId = client.session.uniqueId; // convenience
|
||||
|
||||
Events.emit(Events.getSystemEvents().UserLogin, { user } );
|
||||
|
||||
async.parallel(
|
||||
[
|
||||
function setTheme(callback) {
|
||||
setClientTheme(client, user.properties.theme_id);
|
||||
setClientTheme(client, user.properties[UserProps.ThemeId]);
|
||||
return callback(null);
|
||||
},
|
||||
function updateSystemLoginCount(callback) {
|
||||
return StatLog.incrementSystemStat('login_count', 1, callback);
|
||||
return StatLog.incrementSystemStat('login_count', 1, callback); // :TODO: create system_property.js
|
||||
},
|
||||
function recordLastLogin(callback) {
|
||||
return StatLog.setUserStat(user, 'last_login_timestamp', StatLog.now, callback);
|
||||
return StatLog.setUserStat(user, UserProps.LastLoginTs, StatLog.now, callback);
|
||||
},
|
||||
function updateUserLoginCount(callback) {
|
||||
return StatLog.incrementUserStat(user, 'login_count', 1, callback);
|
||||
return StatLog.incrementUserStat(user, UserProps.LoginCount, 1, callback);
|
||||
},
|
||||
function recordLoginHistory(callback) {
|
||||
const loginHistoryMax = Config().statLog.systemEvents.loginHistoryMax;
|
||||
|
|
|
@ -11,7 +11,7 @@ module.exports = {
|
|||
PassPbkdf2Salt : 'pw_pbkdf2_salt',
|
||||
PassPbkdf2Dk : 'pw_pbkdf2_dk',
|
||||
|
||||
AccountStatus : 'account_status',
|
||||
AccountStatus : 'account_status', // See User.AccountStatus enum
|
||||
|
||||
RealName : 'real_name',
|
||||
Sex : 'sex',
|
||||
|
@ -24,10 +24,14 @@ module.exports = {
|
|||
TermWidth : 'term_width',
|
||||
ThemeId : 'theme_id',
|
||||
AccountCreated : 'account_created',
|
||||
LastLoginTs : 'last_login_timestamp',
|
||||
LoginCount : 'login_count',
|
||||
|
||||
DownloadQueue : 'dl_queue', // download_queue.js
|
||||
|
||||
FailedLoginAttempts : 'failed_login_attempts',
|
||||
AccountLockedTs : 'account_locked_timestamp',
|
||||
AccountLockedPrevStatus : 'account_locked_prev_status', // previous account status
|
||||
AccountLockedPrevStatus : 'account_locked_prev_status', // previous account status before lock out
|
||||
|
||||
EmailPwResetToken : 'email_password_reset_token',
|
||||
EmailPwResetTokenTs : 'email_password_reset_token_ts',
|
||||
|
|
|
@ -59,7 +59,7 @@ class WebPasswordReset {
|
|||
}
|
||||
|
||||
User.getUser(userId, (err, user) => {
|
||||
if(err || !user.properties.email_address) {
|
||||
if(err || !user.properties[UserProps.EmailAddress]) {
|
||||
return callback(Errors.DoesNotExist('No email address associated with this user'));
|
||||
}
|
||||
|
||||
|
@ -105,13 +105,13 @@ class WebPasswordReset {
|
|||
function buildAndSendEmail(user, textTemplate, htmlTemplate, callback) {
|
||||
const sendMail = require('./email.js').sendMail;
|
||||
|
||||
const resetUrl = webServer.instance.buildUrl(`/reset_password?token=${user.properties.email_password_reset_token}`);
|
||||
const resetUrl = webServer.instance.buildUrl(`/reset_password?token=${user.properties[UserProps.EmailPwResetToken]}`);
|
||||
|
||||
function replaceTokens(s) {
|
||||
return s
|
||||
.replace(/%BOARDNAME%/g, Config().general.boardName)
|
||||
.replace(/%USERNAME%/g, user.username)
|
||||
.replace(/%TOKEN%/g, user.properties.email_password_reset_token)
|
||||
.replace(/%TOKEN%/g, user.properties[UserProps.EmailPwResetToken])
|
||||
.replace(/%RESET_URL%/g, resetUrl)
|
||||
;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ class WebPasswordReset {
|
|||
}
|
||||
|
||||
const message = {
|
||||
to : `${user.properties.display_name||user.username} <${user.properties.email_address}>`,
|
||||
to : `${user.properties[UserProps.RealName]||user.username} <${user.properties[UserProps.EmailAddress]}>`,
|
||||
// from will be filled in
|
||||
subject : 'Forgot Password',
|
||||
text : textTemplate,
|
||||
|
|
Loading…
Reference in New Issue