Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

AEM6.3 providing access to group for a particular component on a page on author

srinivas_chann1
Level 7
Level 7

Hi,

 

Could some one help me the below query

 

On Author if there is any way that on page where there are many custom components are available.I mean the components   that at code level will under /apps/project

 

For a specific component  on that page how to restrict the edit access to a particular  group .

 

So that users of that particular group can edit the dialog where as for other users the dialog appears hidden or in disabled state

 

Thanks

1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Please check this article I have written for same

https://aemlab.blogspot.com/2018/11/aem-restrict-component-editing-and.html

 

In component Model you can write a check or you can write a filter as well, if you have more than one component.

 

try {
   boolean decoration=false;
   User currentUser = request.getResourceResolver().adaptTo(User.class);
   
   if(currentUser.isAdmin())
    return;
   
   Iterator<Group> currentUserGroups = currentUser.memberOf();

   while (currentUserGroups.hasNext()) {
    Group grp = (Group) currentUserGroups.next();
    if(grp.getID().equals(GROUP)) {
     decoration =true;
     return;
    }
   }

   ComponentContext cc = WCMUtils.getComponentContext(request);
   cc.setDecorate(decoration);
  } catch (Exception e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   logger.info(e.getMessage());
  }

View solution in original post

4 Replies
vanegi
Employee
Employee

This can be done by just removing permissions of that component for those particular users, you can do groups segregation and add users on those groups ,which has permission to access those components.

 

Capture.JPG

srinivas_chann1
Level 7
Level 7

Hi,

 

Thanks for the input i did try this but in touch ui dialog it shows copy and delete options,but did remove the configure option by this way

Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Please check this article I have written for same

https://aemlab.blogspot.com/2018/11/aem-restrict-component-editing-and.html

 

In component Model you can write a check or you can write a filter as well, if you have more than one component.

 

try {
   boolean decoration=false;
   User currentUser = request.getResourceResolver().adaptTo(User.class);
   
   if(currentUser.isAdmin())
    return;
   
   Iterator<Group> currentUserGroups = currentUser.memberOf();

   while (currentUserGroups.hasNext()) {
    Group grp = (Group) currentUserGroups.next();
    if(grp.getID().equals(GROUP)) {
     decoration =true;
     return;
    }
   }

   ComponentContext cc = WCMUtils.getComponentContext(request);
   cc.setDecorate(decoration);
  } catch (Exception e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   logger.info(e.getMessage());
  }

View solution in original post

srinivas_chann1
Level 7
Level 7

Hi Arun ,

 

I noticed one more issue when we set using decorate the actual component dialog in hidden in touch ui ,but the top " Inheritance Paragraph System" dialog start showing when we click in the area of the component, but same issue does not happen in classic .

 

srinivas_chann1_0-1594996433485.png

 

 

Any inputs as how this could be overcome

 

 

Thanks