* Some more JSON -> HJSON cleanup
* More work on ACS system conditional matching. Now functional within menus. Still more work to go on various ACS checks themselves. * Use ACS for new user path: If new user requires activation, they will see 'DONE' then get logged off
This commit is contained in:
parent
03f9ad4789
commit
688e46bc47
|
@ -792,6 +792,7 @@ module.exports = (function() {
|
|||
var user = options.client.user;
|
||||
|
||||
var _ = require('lodash');
|
||||
var assert = require('assert');
|
||||
|
||||
function checkAccess(acsCode, value) {
|
||||
try {
|
||||
|
@ -802,6 +803,18 @@ module.exports = (function() {
|
|||
AG : function ageGreaterOrEqualThan() {
|
||||
return !isNaN(value) && user.getAge() >= value;
|
||||
},
|
||||
AS : function accountStatus() {
|
||||
|
||||
if(_.isNumber(value)) {
|
||||
value = [ value ];
|
||||
}
|
||||
|
||||
assert(_.isArray(value));
|
||||
|
||||
return _.findIndex(value, function cmp(accStatus) {
|
||||
return parseInt(accStatus, 10) === parseInt(user.properties.account_status, 10);
|
||||
}) > -1;
|
||||
},
|
||||
EC : function isEncoding() {
|
||||
switch(value) {
|
||||
case 0 : return 'cp437' === client.term.outputEncoding.toLowerCase();
|
||||
|
@ -814,13 +827,9 @@ module.exports = (function() {
|
|||
return false;
|
||||
}
|
||||
|
||||
value.forEach(function grpEntry(groupName) {
|
||||
if(user.isGroupMember(groupName)) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
return _.findIndex(value, function cmp(groupName) {
|
||||
return user.isGroupMember(groupName);
|
||||
}) > - 1;
|
||||
},
|
||||
NN : function isNode() {
|
||||
return client.node === value;
|
||||
|
|
|
@ -14,11 +14,11 @@ function getConditionalValue(client, condArray, memberName) {
|
|||
assert(_.isArray(condArray));
|
||||
assert(_.isString(memberName));
|
||||
|
||||
console.log(condArray)
|
||||
|
||||
condArray.forEach(function cond(c) {
|
||||
if(acsParser.parse(c.acs, { client : client })) {
|
||||
return c[memberName];
|
||||
}
|
||||
var matchCond = _.find(condArray, function cmp(cond) {
|
||||
return acsParser.parse(cond.acs, { client : client } );
|
||||
});
|
||||
|
||||
if(matchCond) {
|
||||
return matchCond[memberName];
|
||||
}
|
||||
}
|
|
@ -146,7 +146,7 @@ function MenuModule(options) {
|
|||
|
||||
this.autoNextMenu = function() {
|
||||
function goNext() {
|
||||
if(_.isString(self.menuConfig.next)) {
|
||||
if(_.isString(self.menuConfig.next) || _.isArray(self.menuConfig.next)) {
|
||||
menuUtil.handleNext(self.client, self.menuConfig.next);
|
||||
} else {
|
||||
self.prevMenu();
|
||||
|
@ -179,6 +179,10 @@ function MenuModule(options) {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.haveNext = function() {
|
||||
return (_.isString(this.menuConfig.next) || _.isArray(this.menuConfig.next));
|
||||
};
|
||||
}
|
||||
|
||||
require('util').inherits(MenuModule, PluginModule);
|
||||
|
@ -215,6 +219,14 @@ MenuModule.prototype.restoreSavedState = function(savedState) {
|
|||
};
|
||||
|
||||
MenuModule.prototype.nextMenu = function(cb) {
|
||||
//
|
||||
// If we don't actually have |next|, we'll go previous
|
||||
//
|
||||
if(!this.haveNext()) {
|
||||
this.prevMenu(cb);
|
||||
return;
|
||||
}
|
||||
|
||||
// :TODO: this, prevMenu(), and gotoMenu() need a default |cb| handler if none is supplied.
|
||||
// ...if the error is that we do not meet ACS requirements and did not get a match, then what?
|
||||
if(!cb) {
|
||||
|
|
|
@ -46,24 +46,10 @@ MenuStack.prototype.next = function(cb) {
|
|||
assert(currentModuleInfo, 'Empty menu stack!');
|
||||
|
||||
var menuConfig = currentModuleInfo.instance.menuConfig;
|
||||
|
||||
/*
|
||||
:TODO: next should allow for conditionals based on ACS
|
||||
|
||||
next: [
|
||||
{ acs: "GM[sysops]|U1", next: theNextMenu },
|
||||
...
|
||||
]
|
||||
|
||||
acsUtil.getAcsConditionMatch(cond, memberName) -> value | undefined
|
||||
(memberName = "next")
|
||||
*/
|
||||
|
||||
var next;
|
||||
|
||||
if(_.isArray(menuConfig.next)) {
|
||||
next = acsUtil.getConditionalValue(this.client, menuConfig.next, 'next');
|
||||
console.log('conditional next: ' + next);
|
||||
if(!next) {
|
||||
cb(new Error('No matching condition for \'next\'!'));
|
||||
return;
|
||||
|
@ -75,12 +61,12 @@ MenuStack.prototype.next = function(cb) {
|
|||
return;
|
||||
}
|
||||
|
||||
if(menuConfig.next === currentModuleInfo.name) {
|
||||
if(next === currentModuleInfo.name) {
|
||||
cb(new Error('Menu config \'next\' specifies current menu!'));
|
||||
return;
|
||||
}
|
||||
|
||||
this.goto(menuConfig.next, { }, cb);
|
||||
this.goto(next, { }, cb);
|
||||
};
|
||||
|
||||
MenuStack.prototype.prev = function(cb) {
|
||||
|
|
|
@ -10,6 +10,7 @@ var asset = require('./asset.js');
|
|||
var theme = require('./theme.js');
|
||||
var configCache = require('./config_cache.js');
|
||||
var MCIViewFactory = require('./mci_view_factory.js').MCIViewFactory;
|
||||
var acsUtil = require('./acs_util.js');
|
||||
|
||||
var fs = require('fs');
|
||||
var paths = require('path');
|
||||
|
@ -220,8 +221,12 @@ function handleAction(client, formData, conf) {
|
|||
}
|
||||
|
||||
function handleNext(client, nextSpec, conf) {
|
||||
assert(_.isString(nextSpec));
|
||||
|
||||
assert(_.isString(nextSpec) || _.isArray(nextSpec));
|
||||
|
||||
if(_.isArray(nextSpec)) {
|
||||
nextSpec = acsUtil.getConditionalValue(client, nextSpec, 'next');
|
||||
}
|
||||
|
||||
var nextAsset = asset.getAssetWithShorthand(nextSpec, 'menu');
|
||||
|
||||
conf = conf || {};
|
||||
|
|
|
@ -85,9 +85,9 @@ User.StandardPropertyGroups = {
|
|||
};
|
||||
|
||||
User.AccountStatus = {
|
||||
disabled : -1,
|
||||
inactive : 0,
|
||||
active : 1,
|
||||
disabled : 0,
|
||||
inactive : 1,
|
||||
active : 2,
|
||||
};
|
||||
|
||||
User.prototype.load = function(userId, cb) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
var user = options.client.user;
|
||||
|
||||
var _ = require('lodash');
|
||||
var assert = require('assert');
|
||||
|
||||
function checkAccess(acsCode, value) {
|
||||
try {
|
||||
|
@ -14,6 +15,18 @@
|
|||
AG : function ageGreaterOrEqualThan() {
|
||||
return !isNaN(value) && user.getAge() >= value;
|
||||
},
|
||||
AS : function accountStatus() {
|
||||
|
||||
if(_.isNumber(value)) {
|
||||
value = [ value ];
|
||||
}
|
||||
|
||||
assert(_.isArray(value));
|
||||
|
||||
return _.findIndex(value, function cmp(accStatus) {
|
||||
return parseInt(accStatus, 10) === parseInt(user.properties.account_status, 10);
|
||||
}) > -1;
|
||||
},
|
||||
EC : function isEncoding() {
|
||||
switch(value) {
|
||||
case 0 : return 'cp437' === client.term.outputEncoding.toLowerCase();
|
||||
|
@ -26,13 +39,9 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
value.forEach(function grpEntry(groupName) {
|
||||
if(user.isGroupMember(groupName)) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
return _.findIndex(value, function cmp(groupName) {
|
||||
return user.isGroupMember(groupName);
|
||||
}) > - 1;
|
||||
},
|
||||
NN : function isNode() {
|
||||
return client.node === value;
|
||||
|
|
|
@ -119,8 +119,6 @@
|
|||
next: @systemMethod:logoff
|
||||
}
|
||||
/*
|
||||
nua -> send sysop mail -> { active } -> matrix
|
||||
-> you must active -> matrix
|
||||
TODO: display PRINT before this (Obv/2) or NEWUSER1 (Mystic)
|
||||
*/
|
||||
newUserApplication: {
|
||||
|
@ -305,9 +303,16 @@
|
|||
newUserFeedbackToSysOp: {
|
||||
status: Feedback to SysOp
|
||||
module: msg_area_post_fse
|
||||
// :TODO: If the user is auto-approved, login seq. else, DONE.ANS -> Logoff
|
||||
// :TODO: client.nextOrFallback(): go next or fallback. Use in MenuModule base also
|
||||
fallback: fullLoginSequenceLoginArt
|
||||
next: [
|
||||
{
|
||||
acs: AS2
|
||||
next: fullLoginSequenceLoginArt
|
||||
}
|
||||
{
|
||||
acs: !AS2
|
||||
next: newUserInactiveDone
|
||||
}
|
||||
]
|
||||
config: {
|
||||
art: {
|
||||
header: MSGEHDR
|
||||
|
@ -413,6 +418,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
newUserInactiveDone: {
|
||||
desc: Finished with NUA
|
||||
art: DONE
|
||||
options: { pause: true }
|
||||
next: @menu:logoff
|
||||
}
|
||||
|
||||
fullLoginSequenceLoginArt: {
|
||||
desc: Logging In
|
||||
art: WELCOME
|
||||
|
@ -448,12 +460,8 @@
|
|||
prompt: menuCommand
|
||||
submit: [
|
||||
{
|
||||
"value" : { "command" : "G" },
|
||||
"action" : "@menu:logoff"
|
||||
},
|
||||
{
|
||||
"value" : { "command" : "O" },
|
||||
"action" : "@menu:doorPimpWars"
|
||||
value: { command: "G" }
|
||||
action: @menu:logoff
|
||||
}
|
||||
{
|
||||
value: { command: "D" }
|
||||
|
@ -464,21 +472,17 @@
|
|||
action: @menu:mainMenuUserList
|
||||
}
|
||||
{
|
||||
value: { command: "E" }
|
||||
action: @menu:doorTestExample
|
||||
value: { command: "L" }
|
||||
action: @menu:mainMenuLastCallers
|
||||
}
|
||||
{
|
||||
"value" : { "command" : "L" },
|
||||
"action" : "@menu:mainMenuLastCallers"
|
||||
},
|
||||
value: { command: "Y" }
|
||||
action: @menu:mainMenuUserStats
|
||||
}
|
||||
{
|
||||
"value" : { "command" : "Y" },
|
||||
"action" : "@menu:mainMenuUserStats"
|
||||
},
|
||||
{
|
||||
"value" : { "command" : "M" },
|
||||
"action" : "@menu:messageArea"
|
||||
},
|
||||
value: { command: "M" }
|
||||
action: @menu:messageArea
|
||||
}
|
||||
{
|
||||
value: { command: "C" }
|
||||
action: @menu:mainMenuUserConfig
|
||||
|
@ -488,8 +492,8 @@
|
|||
action: @menu:mainMenuSystemStats
|
||||
}
|
||||
{
|
||||
"value" : 1,
|
||||
"action" : "@menu:mainMenu"
|
||||
value: 1
|
||||
action: @menu:mainMenu
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ function AreaPostFSEModule(options) {
|
|||
console.log(msg);
|
||||
}
|
||||
|
||||
self.prevMenu();
|
||||
self.nextMenu();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue