mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-08-03 08:22:02 +02:00
Add menu-level ACS check
This commit is contained in:
parent
475fe596f6
commit
5bd7ecdb88
5 changed files with 80 additions and 28 deletions
15
core/acs.js
15
core/acs.js
|
@ -51,6 +51,19 @@ class ACS {
|
|||
return this.check(area.acs, 'download', ACS.Defaults.FileAreaDownload);
|
||||
}
|
||||
|
||||
hasMenuModuleAccess(modInst) {
|
||||
const acs = _.get(modInst, 'menuConfig.config.acs');
|
||||
if(!_.isString(acs)) {
|
||||
return true; // no ACS check req.
|
||||
}
|
||||
try {
|
||||
return checkAcs(acs, { client : this.client } );
|
||||
} catch(e) {
|
||||
Log.warn( { exception : e, acs : acs }, 'Exception caught checking ACS');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
getConditionalValue(condArray, memberName) {
|
||||
if(!Array.isArray(condArray)) {
|
||||
// no cond array, just use the value
|
||||
|
@ -68,7 +81,7 @@ class ACS {
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
return true; // no acs check req.
|
||||
return true; // no ACS check req.
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -127,6 +127,13 @@ module.exports = class MenuStack {
|
|||
} else {
|
||||
self.client.log.debug( { menuName : name }, 'Goto menu module');
|
||||
|
||||
if(!this.client.acs.hasMenuModuleAccess(modInst)) {
|
||||
if(cb) {
|
||||
return cb(Errors.AccessDenied('No access to this menu'));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// If menuFlags were supplied in menu.hjson, they should win over
|
||||
// anything supplied in code.
|
||||
|
|
|
@ -116,7 +116,7 @@ exports.getModule = class ShowArtModule extends MenuModule {
|
|||
if(!area) {
|
||||
return cb(Errors.DoesNotExist(`No area by areaTag ${key} found`));
|
||||
}
|
||||
return cb(null); // :TODO: REM OVE ME
|
||||
return cb(null); // :TODO: REMOVE ME --- currently NYI
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue