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