...and more UserProps
This commit is contained in:
parent
d11aca571e
commit
f80e07fcf9
12
core/bbs.js
12
core/bbs.js
|
@ -10,6 +10,7 @@ const conf = require('./config.js');
|
||||||
const logger = require('./logger.js');
|
const logger = require('./logger.js');
|
||||||
const database = require('./database.js');
|
const database = require('./database.js');
|
||||||
const resolvePath = require('./misc_util.js').resolvePath;
|
const resolvePath = require('./misc_util.js').resolvePath;
|
||||||
|
const UserProps = require('./user_property.js');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
|
@ -229,18 +230,21 @@ function initialize(cb) {
|
||||||
},
|
},
|
||||||
function getOpProps(opUserName, next) {
|
function getOpProps(opUserName, next) {
|
||||||
const propLoadOpts = {
|
const propLoadOpts = {
|
||||||
names : [ 'real_name', 'sex', 'email_address', 'location', 'affiliation' ],
|
names : [
|
||||||
|
UserProps.RealName, UserProps.Sex, UserProps.EmailAddress,
|
||||||
|
UserProps.Location, UserProps.Affiliations,
|
||||||
|
],
|
||||||
};
|
};
|
||||||
User.loadProperties(User.RootUserID, propLoadOpts, (err, opProps) => {
|
User.loadProperties(User.RootUserID, propLoadOpts, (err, opProps) => {
|
||||||
return next(err, opUserName, opProps);
|
return next(err, opUserName, opProps, propLoadOpts);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
(err, opUserName, opProps) => {
|
(err, opUserName, opProps, propLoadOpts) => {
|
||||||
const StatLog = require('./stat_log.js');
|
const StatLog = require('./stat_log.js');
|
||||||
|
|
||||||
if(err) {
|
if(err) {
|
||||||
[ 'username', 'real_name', 'sex', 'email_address', 'location', 'affiliation' ].forEach(v => {
|
propLoadOpts.concat('username').forEach(v => {
|
||||||
StatLog.setNonPeristentSystemStat(`sysop_${v}`, 'N/A');
|
StatLog.setNonPeristentSystemStat(`sysop_${v}`, 'N/A');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,6 +7,7 @@ const StatLog = require('./stat_log.js');
|
||||||
const User = require('./user.js');
|
const User = require('./user.js');
|
||||||
const sysDb = require('./database.js').dbs.system;
|
const sysDb = require('./database.js').dbs.system;
|
||||||
const { Errors } = require('./enig_error.js');
|
const { Errors } = require('./enig_error.js');
|
||||||
|
const UserProps = require('./user_property.js');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
@ -165,7 +166,7 @@ exports.getModule = class LastCallersModule extends MenuModule {
|
||||||
|
|
||||||
loadUserForHistoryItems(loginHistory, cb) {
|
loadUserForHistoryItems(loginHistory, cb) {
|
||||||
const getPropOpts = {
|
const getPropOpts = {
|
||||||
names : [ 'real_name', 'location', 'affiliation' ]
|
names : [ UserProps.RealName, UserProps.Location, UserProps.Affiliations ]
|
||||||
};
|
};
|
||||||
|
|
||||||
const actionIndicatorNames = _.map(this.actionIndicators, (v, k) => k);
|
const actionIndicatorNames = _.map(this.actionIndicators, (v, k) => k);
|
||||||
|
@ -185,9 +186,9 @@ exports.getModule = class LastCallersModule extends MenuModule {
|
||||||
item.userName = item.text = userName;
|
item.userName = item.text = userName;
|
||||||
|
|
||||||
User.loadProperties(item.userId, getPropOpts, (err, props) => {
|
User.loadProperties(item.userId, getPropOpts, (err, props) => {
|
||||||
item.location = (props && props.location) || '';
|
item.location = (props && props[UserProps.Location]) || '';
|
||||||
item.affiliation = item.affils = (props && props.affiliation) || '';
|
item.affiliation = item.affils = (props && props[UserProps.Affiliations]) || '';
|
||||||
item.realName = (props && props.real_name) || '';
|
item.realName = (props && props[UserProps.RealName]) || '';
|
||||||
|
|
||||||
if(!indicatorSumsSql) {
|
if(!indicatorSumsSql) {
|
||||||
return next(null, item);
|
return next(null, item);
|
||||||
|
|
10
core/user.js
10
core/user.js
|
@ -203,8 +203,8 @@ module.exports = class User {
|
||||||
},
|
},
|
||||||
function getDkWithSalt(props, callback) {
|
function getDkWithSalt(props, callback) {
|
||||||
// get DK from stored salt and password provided
|
// get DK from stored salt and password provided
|
||||||
User.generatePasswordDerivedKey(password, props.pw_pbkdf2_salt, (err, dk) => {
|
User.generatePasswordDerivedKey(password, props[UserProps.PassPbkdf2Salt], (err, dk) => {
|
||||||
return callback(err, dk, props.pw_pbkdf2_dk);
|
return callback(err, dk, props[UserProps.PassPbkdf2Dk]);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function validateAuth(passDk, propsDk, callback) {
|
function validateAuth(passDk, propsDk, callback) {
|
||||||
|
@ -516,8 +516,8 @@ module.exports = class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
const newProperties = {
|
const newProperties = {
|
||||||
pw_pbkdf2_salt : info.salt,
|
[ UserProps.PassPbkdf2Salt ] : info.salt,
|
||||||
pw_pbkdf2_dk : info.dk,
|
[ UserProps.PassPbkdf2Dk ] : info.dk,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.persistProperties(newProperties, err => {
|
this.persistProperties(newProperties, err => {
|
||||||
|
@ -596,7 +596,7 @@ module.exports = class User {
|
||||||
WHERE id = (
|
WHERE id = (
|
||||||
SELECT user_id
|
SELECT user_id
|
||||||
FROM user_property
|
FROM user_property
|
||||||
WHERE prop_name='real_name' AND prop_value LIKE ?
|
WHERE prop_name='${UserProps.RealName}' AND prop_value LIKE ?
|
||||||
);`,
|
);`,
|
||||||
[ realName ],
|
[ realName ],
|
||||||
(err, row) => {
|
(err, row) => {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
const { MenuModule } = require('./menu_module.js');
|
const { MenuModule } = require('./menu_module.js');
|
||||||
const { getUserList } = require('./user.js');
|
const { getUserList } = require('./user.js');
|
||||||
const { Errors } = require('./enig_error.js');
|
const { Errors } = require('./enig_error.js');
|
||||||
|
const UserProps = require('./user_property.js');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
@ -44,7 +45,7 @@ exports.getModule = class UserListModule extends MenuModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchOpts = {
|
const fetchOpts = {
|
||||||
properties : [ 'real_name', 'location', 'affiliation', 'last_login_timestamp' ],
|
properties : [ UserProps.RealName, UserProps.Location, UserProps.Affiliations, UserProps.LastLoginTs ],
|
||||||
propsCamelCase : true, // e.g. real_name -> realName
|
propsCamelCase : true, // e.g. real_name -> realName
|
||||||
};
|
};
|
||||||
getUserList(fetchOpts, (err, userList) => {
|
getUserList(fetchOpts, (err, userList) => {
|
||||||
|
|
Loading…
Reference in New Issue