Hi

I have a tag that shows edit bar but only if the user has a role in specified 
list.
Something like

<cms:adminOnly>
 <nem:ifUserRoleMatches roles="superuser,webmaster">
  <cms:editBar paragraph="np-logo" contentNodeName="logo" editLabel="redefine" 
moveLabel="" deleteLabel="" />
 </nem:ifUserRoleMatches>
</cms:adminOnly>

In the tag I get the user from MgnlContext:

        User user = MgnlContext.getUser();
        Collection userRoles = user.getRoles();
        Collection userGroups = user.getGroups();

Checking the direct assigned user roles is fine...
But the problem I am facing is checking the user roles from the groups the user 
belongs to...
I iterate over the specified roles (after creating a list out of them) and do:

If (Security.getGroupManager().getGroup(grpName).hasRole(r)) {
        //...user has the role...
}

This always throws AccessDenied exception because the "regular" users I define 
do not have access to USERGROUPS repository....


How can I get around this?
I just want to check if user has a role via group membership (since 
user.getRoles() only returns direct assigned roles and not roles users may have 
indirectly because they belong to a group)...

Any idea would be greatly appreciated....


Amir
         
----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/developer.html
----------------------------------------------------------------

Reply via email to