rbac and licenses
This commit is contained in:
17
utils.js
17
utils.js
@@ -63,7 +63,6 @@ module.exports = startMenuItems = async function (app, objectGuid) {
|
||||
|
||||
plugin.menu.items = (plugin.menu.items || []).map(item => {
|
||||
|
||||
const resource = item.label;
|
||||
const requiredPermissions = item.permissions || [];
|
||||
|
||||
const debugTrace = [];
|
||||
@@ -77,25 +76,25 @@ module.exports = startMenuItems = async function (app, objectGuid) {
|
||||
const scopeMatch =
|
||||
userPerm.scope === required.scope;
|
||||
|
||||
const resourceMatch =
|
||||
!userPerm.resource ||
|
||||
userPerm.resource === 'ALL' ||
|
||||
userPerm.resource === required.resource;
|
||||
|
||||
const actionMatch =
|
||||
userPerm.action === 'ALL' ||
|
||||
userPerm.action === required.action ||
|
||||
required.action === 'ALL';
|
||||
|
||||
const resourceMatch =
|
||||
!userPerm.resource ||
|
||||
userPerm.resource === 'ALL' ||
|
||||
userPerm.resource === resource;
|
||||
|
||||
const result = scopeMatch && actionMatch && resourceMatch;
|
||||
const result = scopeMatch && resourceMatch && actionMatch;
|
||||
|
||||
if (debug) {
|
||||
debugTrace.push({
|
||||
userPerm,
|
||||
required,
|
||||
scopeMatch,
|
||||
actionMatch,
|
||||
resourceMatch,
|
||||
actionMatch,
|
||||
result
|
||||
});
|
||||
}
|
||||
@@ -105,7 +104,7 @@ module.exports = startMenuItems = async function (app, objectGuid) {
|
||||
});
|
||||
|
||||
if (debug) {
|
||||
log(`\nMENU ITEM: ${item.label} - AUTHORIZED:', ${authorized} - TRACE:', ${debugTrace}`);
|
||||
log(`\nMENU ITEM: ${item.label} - AUTHORIZED:', ${authorized} - TRACE:', ${JSON.stringify(debugTrace)}`);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user