Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!
SOLVED

How to restrict users to access some of the pages in website

Avatar

Level 3

Hi Team,

 

I have a website in AEM Cloud, where once the user is authenticated, I want them to see page according to their permissions.

How can I restrict the users to see only some of the page in navigation bar but not all as per their permission in authenticated group.

 

Thanks,

SD 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @SDusane 

we had implement same using:
CUG : To protect page(s)/tree

LinkTransformer : To add a hide class or custom data attribute 'cug-protected-link' to all protected links while generating page. Alternatively you can do same in sling model if this is just for navigation component. we had to apply this globally so went with sling rewrite pipeline.

Servlet : Calling a servlet(POST with all the 'cug-protected-link'  links ) on page load, servlet will return a json response with payload links and visibility status based on user(current session).

 

based on servlet response unhide 'cug-protected-link'.

considering creating dictionary with expiry in user's localStorge will help to reduce number of call to server and help with performance.




Arun Patidar

View solution in original post

2 Replies

Avatar

Level 5

@SDusane 

You can use sling model to fetch the groups associated with the user and check if user is part of the required group.

Then you can show/hide html elements conditionally in navigation bar by calling that sling model in sightly code using use API

Avatar

Correct answer by
Community Advisor

Hi @SDusane 

we had implement same using:
CUG : To protect page(s)/tree

LinkTransformer : To add a hide class or custom data attribute 'cug-protected-link' to all protected links while generating page. Alternatively you can do same in sling model if this is just for navigation component. we had to apply this globally so went with sling rewrite pipeline.

Servlet : Calling a servlet(POST with all the 'cug-protected-link'  links ) on page load, servlet will return a json response with payload links and visibility status based on user(current session).

 

based on servlet response unhide 'cug-protected-link'.

considering creating dictionary with expiry in user's localStorge will help to reduce number of call to server and help with performance.




Arun Patidar