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.
Yes, the rule engine is synchronous. At this point all evaluators should be sync too.
Ok, so how can we achieve that correctly? Any hint?
Thank you.
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
Discussions, help and advice about the Alfresco Development Framework.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.