* ACS system is now to chars for all IDs, e.g. ID, LC, etc.

This commit is contained in:
Bryan Ashby 2015-11-13 16:13:20 -07:00
parent 882c8fbdfb
commit 03f9ad4789
4 changed files with 59 additions and 72 deletions

View File

@ -58,21 +58,19 @@ module.exports = (function() {
peg$c19 = { type: "literal", value: "[", description: "\"[\"" }, peg$c19 = { type: "literal", value: "[", description: "\"[\"" },
peg$c20 = "]", peg$c20 = "]",
peg$c21 = { type: "literal", value: "]", description: "\"]\"" }, peg$c21 = { type: "literal", value: "]", description: "\"]\"" },
peg$c22 = function(n, a) { return checkAccess(n, a); }, peg$c22 = function(acs, a) { return checkAccess(acs, a); },
peg$c23 = /^[A-Z]/, peg$c23 = /^[A-Z]/,
peg$c24 = { type: "class", value: "[A-Z]", description: "[A-Z]" }, peg$c24 = { type: "class", value: "[A-Z]", description: "[A-Z]" },
peg$c25 = function(c) { return c.join(''); }, peg$c25 = function(c) { return c.join(''); },
peg$c26 = /^[A-Z=]/, peg$c26 = /^[A-Za-z0-9\-_+]/,
peg$c27 = { type: "class", value: "[A-Z\\=]", description: "[A-Z\\=]" }, peg$c27 = { type: "class", value: "[A-Za-z0-9\\-_\\+]", description: "[A-Za-z0-9\\-_\\+]" },
peg$c28 = /^[A-Za-z0-9\-_+]/, peg$c28 = function(a) { return a.join('') },
peg$c29 = { type: "class", value: "[A-Za-z0-9\\-_\\+]", description: "[A-Za-z0-9\\-_\\+]" }, peg$c29 = function(v) { return v; },
peg$c30 = function(a) { return a.join('') }, peg$c30 = function(start, last) { return start.concat(last); },
peg$c31 = function(v) { return v; }, peg$c31 = function(l) { return l; },
peg$c32 = function(start, last) { return start.concat(last); }, peg$c32 = /^[0-9]/,
peg$c33 = function(l) { return l; }, peg$c33 = { type: "class", value: "[0-9]", description: "[0-9]" },
peg$c34 = /^[0-9]/, peg$c34 = function(d) { return parseInt(d.join(''), 10); },
peg$c35 = { type: "class", value: "[0-9]", description: "[0-9]" },
peg$c36 = function(d) { return parseInt(d.join(''), 10); },
peg$currPos = 0, peg$currPos = 0,
peg$savedPos = 0, peg$savedPos = 0,
@ -535,7 +533,7 @@ module.exports = (function() {
var s0, s1, s2; var s0, s1, s2;
s0 = peg$currPos; s0 = peg$currPos;
s1 = peg$parsename(); s1 = peg$parseacsCode();
if (s1 !== peg$FAILED) { if (s1 !== peg$FAILED) {
s2 = peg$parsearg(); s2 = peg$parsearg();
if (s2 !== peg$FAILED) { if (s2 !== peg$FAILED) {
@ -554,7 +552,7 @@ module.exports = (function() {
return s0; return s0;
} }
function peg$parsename() { function peg$parseacsCode() {
var s0, s1, s2, s3; var s0, s1, s2, s3;
s0 = peg$currPos; s0 = peg$currPos;
@ -590,15 +588,6 @@ module.exports = (function() {
s1 = peg$c25(s1); s1 = peg$c25(s1);
} }
s0 = s1; s0 = s1;
if (s0 === peg$FAILED) {
if (peg$c26.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c27); }
}
}
return s0; return s0;
} }
@ -608,22 +597,22 @@ module.exports = (function() {
s0 = peg$currPos; s0 = peg$currPos;
s1 = []; s1 = [];
if (peg$c28.test(input.charAt(peg$currPos))) { if (peg$c26.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos); s2 = input.charAt(peg$currPos);
peg$currPos++; peg$currPos++;
} else { } else {
s2 = peg$FAILED; s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c29); } if (peg$silentFails === 0) { peg$fail(peg$c27); }
} }
if (s2 !== peg$FAILED) { if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) {
s1.push(s2); s1.push(s2);
if (peg$c28.test(input.charAt(peg$currPos))) { if (peg$c26.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos); s2 = input.charAt(peg$currPos);
peg$currPos++; peg$currPos++;
} else { } else {
s2 = peg$FAILED; s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c29); } if (peg$silentFails === 0) { peg$fail(peg$c27); }
} }
} }
} else { } else {
@ -631,7 +620,7 @@ module.exports = (function() {
} }
if (s1 !== peg$FAILED) { if (s1 !== peg$FAILED) {
peg$savedPos = s0; peg$savedPos = s0;
s1 = peg$c30(s1); s1 = peg$c28(s1);
} }
s0 = s1; s0 = s1;
@ -653,7 +642,7 @@ module.exports = (function() {
s6 = peg$parseoptWs(); s6 = peg$parseoptWs();
if (s6 !== peg$FAILED) { if (s6 !== peg$FAILED) {
peg$savedPos = s2; peg$savedPos = s2;
s3 = peg$c31(s3); s3 = peg$c29(s3);
s2 = s3; s2 = s3;
} else { } else {
peg$currPos = s2; peg$currPos = s2;
@ -683,7 +672,7 @@ module.exports = (function() {
s6 = peg$parseoptWs(); s6 = peg$parseoptWs();
if (s6 !== peg$FAILED) { if (s6 !== peg$FAILED) {
peg$savedPos = s2; peg$savedPos = s2;
s3 = peg$c31(s3); s3 = peg$c29(s3);
s2 = s3; s2 = s3;
} else { } else {
peg$currPos = s2; peg$currPos = s2;
@ -706,7 +695,7 @@ module.exports = (function() {
s2 = peg$parseargVar(); s2 = peg$parseargVar();
if (s2 !== peg$FAILED) { if (s2 !== peg$FAILED) {
peg$savedPos = s0; peg$savedPos = s0;
s1 = peg$c32(s1, s2); s1 = peg$c30(s1, s2);
s0 = s1; s0 = s1;
} else { } else {
peg$currPos = s0; peg$currPos = s0;
@ -731,7 +720,7 @@ module.exports = (function() {
s3 = peg$parselistClose(); s3 = peg$parselistClose();
if (s3 !== peg$FAILED) { if (s3 !== peg$FAILED) {
peg$savedPos = s0; peg$savedPos = s0;
s1 = peg$c33(s2); s1 = peg$c31(s2);
s0 = s1; s0 = s1;
} else { } else {
peg$currPos = s0; peg$currPos = s0;
@ -754,22 +743,22 @@ module.exports = (function() {
s0 = peg$currPos; s0 = peg$currPos;
s1 = []; s1 = [];
if (peg$c34.test(input.charAt(peg$currPos))) { if (peg$c32.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos); s2 = input.charAt(peg$currPos);
peg$currPos++; peg$currPos++;
} else { } else {
s2 = peg$FAILED; s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c35); } if (peg$silentFails === 0) { peg$fail(peg$c33); }
} }
if (s2 !== peg$FAILED) { if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) {
s1.push(s2); s1.push(s2);
if (peg$c34.test(input.charAt(peg$currPos))) { if (peg$c32.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos); s2 = input.charAt(peg$currPos);
peg$currPos++; peg$currPos++;
} else { } else {
s2 = peg$FAILED; s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c35); } if (peg$silentFails === 0) { peg$fail(peg$c33); }
} }
} }
} else { } else {
@ -777,7 +766,7 @@ module.exports = (function() {
} }
if (s1 !== peg$FAILED) { if (s1 !== peg$FAILED) {
peg$savedPos = s0; peg$savedPos = s0;
s1 = peg$c36(s1); s1 = peg$c34(s1);
} }
s0 = s1; s0 = s1;
@ -804,13 +793,13 @@ module.exports = (function() {
var _ = require('lodash'); var _ = require('lodash');
function checkAccess(name, value) { function checkAccess(acsCode, value) {
try { try {
return { return {
'=' : function isLocalConnection() { LC : function isLocalConnection() {
return client.isLocal(); return client.isLocal();
}, },
A : function ageGreaterOrEqualThan() { AG : function ageGreaterOrEqualThan() {
return !isNaN(value) && user.getAge() >= value; return !isNaN(value) && user.getAge() >= value;
}, },
EC : function isEncoding() { EC : function isEncoding() {
@ -833,21 +822,21 @@ module.exports = (function() {
return false; return false;
}, },
N : function isNode() { NN : function isNode() {
return client.node === value; return client.node === value;
}, },
P : function numberOfPosts() { NP : function numberOfPosts() {
// :TODO: implement me!!!! // :TODO: implement me!!!!
return false; return false;
}, },
Q : function numberOfCalls() { NC : function numberOfCalls() {
// :TODO: implement me!! // :TODO: implement me!!
return false; return false;
}, },
SC : function isSecerConnection() { SC : function isSecerConnection() {
return client.session.isSecure; return client.session.isSecure;
}, },
T : function minutesLeft() { ML : function minutesLeft() {
// :TODO: implement me! // :TODO: implement me!
return false; return false;
}, },
@ -871,10 +860,10 @@ module.exports = (function() {
TW : function termWidth() { TW : function termWidth() {
return !isNaN(value) && client.term.termWidth >= value; return !isNaN(value) && client.term.termWidth >= value;
}, },
U : function isUserId(value) { ID : function isUserId(value) {
return user.userId === value; return user.userId === value;
}, },
W : function isOneOfDayOfWeek() { WD : function isOneOfDayOfWeek() {
// :TODO: return true if DoW // :TODO: return true if DoW
if(_.isNumber(value)) { if(_.isNumber(value)) {
@ -883,13 +872,13 @@ module.exports = (function() {
} }
return false; return false;
}, },
Y : function isMinutesPastMidnight() { MM : function isMinutesPastMidnight() {
// :TODO: return true if value is >= minutes past midnight sys time // :TODO: return true if value is >= minutes past midnight sys time
return false; return false;
} }
}[name](value); }[acsCode](value);
} catch (e) { } catch (e) {
client.log.warn( { name : name, value : value }, 'Invalid ACS string!'); client.log.warn( { acsCode : acsCode, value : value }, 'Invalid ACS string!');
return false; return false;
} }
} }

View File

@ -215,6 +215,13 @@ MenuModule.prototype.restoreSavedState = function(savedState) {
}; };
MenuModule.prototype.nextMenu = function(cb) { MenuModule.prototype.nextMenu = function(cb) {
// :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) {
cb = function(err) {
console.log(err)
}
}
this.client.menuStack.next(cb); this.client.menuStack.next(cb);
}; };

View File

@ -5,13 +5,13 @@
var _ = require('lodash'); var _ = require('lodash');
function checkAccess(name, value) { function checkAccess(acsCode, value) {
try { try {
return { return {
'=' : function isLocalConnection() { LC : function isLocalConnection() {
return client.isLocal(); return client.isLocal();
}, },
A : function ageGreaterOrEqualThan() { AG : function ageGreaterOrEqualThan() {
return !isNaN(value) && user.getAge() >= value; return !isNaN(value) && user.getAge() >= value;
}, },
EC : function isEncoding() { EC : function isEncoding() {
@ -34,21 +34,21 @@
return false; return false;
}, },
N : function isNode() { NN : function isNode() {
return client.node === value; return client.node === value;
}, },
P : function numberOfPosts() { NP : function numberOfPosts() {
// :TODO: implement me!!!! // :TODO: implement me!!!!
return false; return false;
}, },
Q : function numberOfCalls() { NC : function numberOfCalls() {
// :TODO: implement me!! // :TODO: implement me!!
return false; return false;
}, },
SC : function isSecerConnection() { SC : function isSecerConnection() {
return client.session.isSecure; return client.session.isSecure;
}, },
T : function minutesLeft() { ML : function minutesLeft() {
// :TODO: implement me! // :TODO: implement me!
return false; return false;
}, },
@ -72,10 +72,10 @@
TW : function termWidth() { TW : function termWidth() {
return !isNaN(value) && client.term.termWidth >= value; return !isNaN(value) && client.term.termWidth >= value;
}, },
U : function isUserId(value) { ID : function isUserId(value) {
return user.userId === value; return user.userId === value;
}, },
W : function isOneOfDayOfWeek() { WD : function isOneOfDayOfWeek() {
// :TODO: return true if DoW // :TODO: return true if DoW
if(_.isNumber(value)) { if(_.isNumber(value)) {
@ -84,13 +84,13 @@
} }
return false; return false;
}, },
Y : function isMinutesPastMidnight() { MM : function isMinutesPastMidnight() {
// :TODO: return true if value is >= minutes past midnight sys time // :TODO: return true if value is >= minutes past midnight sys time
return false; return false;
} }
}[name](value); }[acsCode](value);
} catch (e) { } catch (e) {
client.log.warn( { name : name, value : value }, 'Invalid ACS string!'); client.log.warn( { acsCode : acsCode, value : value }, 'Invalid ACS string!');
return false; return false;
} }
} }
@ -149,11 +149,10 @@ listClose
= ']' = ']'
acsCheck acsCheck
= n:name a:arg { return checkAccess(n, a); } = acs:acsCode a:arg { return checkAccess(acs, a); }
name acsCode
= c:([A-Z][A-Z]) { return c.join(''); } = c:([A-Z][A-Z]) { return c.join(''); }
/ c:[A-Z\=]
argVar argVar
= a:[A-Za-z0-9\-_\+]+ { return a.join('') } = a:[A-Za-z0-9\-_\+]+ { return a.join('') }

View File

@ -76,14 +76,6 @@
login: { login: {
art: USERLOG art: USERLOG
next: fullLoginSequenceLoginArt next: fullLoginSequenceLoginArt
/*
next: [
{
acs: "=N2"
next: fullLoginSequenceLoginArt
}
]
*/
config: { config: {
tooNode: { tooNode: {
art: TOONODE art: TOONODE