08-07-2023 04:44 AM
Hi,
We have created 2 extensions for ADW. I would like to restrict these extensions to some functionnal groups.
We have added a rule for this:
"features": {
"navbar": [
{
"id": "my.ext.nav",
"rules": {
"visible": "app.isAffiche"
},
"items": [
{
"id": "my.ext.main",
"icon": "extension",
"title": "My extension",
"route": "my.ext.route"
}
]
}
]
}And an Evaluator :
import * as rule from './my-ext.service';
extensions.setEvaluators({
'app.isAffiche': rule.isAffiche
});We add rule.isAffiche in the service, it works when we make it send true or false:
But, then I changed to check the user groups:
export const isAffiche = (): boolean =>
{
groupService: GroupService;
let groupService;
const groupsEntries: GroupEntry[] = await groupService.listAllGroupMembershipsForPerson('-me-', {maxItems: 250});
let groupIdList = groupsEntries.map((obj) => obj.entry.id);
groupIdList.forEach(group => {
if (group.includes("My-authorized-group")) {
return true;
}
return false;
});
};But then it doesn’t work anymore. Maybe it is because there is an async call?
Thank you for your help.
08-10-2023 09:53 AM
Yes, the rule engine is synchronous. At this point all evaluators should be sync too.
08-24-2023 05:26 AM
Ok, so how can we achieve that correctly? Any hint?
Thank you.
08-24-2023 10:10 AM
You should already have groups as part o the user loading process: https://github.com/Alfresco/alfresco-content-app/blob/6422c32df3a1c34d0cd35624c5658e25f8942acb/proje...
That means your custom evaluators can check the "context.profile.groups" array
Explore our Alfresco products with the links below. Use labels to filter content by product module.