0

I want to hide a page in navigation component based on the logged in user. I have two approaches in mind. Set permissions on the page's node in CRX-DE; denying it for all users; and then allowing it for specific groups. I have been trying it; not found much success. Else; I can get the id of the logged in user in the jsp and based on the user group; I can set the page's property 'Hide in Navigation' . But I am not able to find how to set that property in jsp. Please suggest.

Edit: I am using the default authentication.I wanted to hide a page from navigation in the default 'list' component. If I use CUG; the users belonging to that group will still be able to see that particular page's link in the list component; and would be asked for login on clicking on that page.I want the link itself to be hidden if the user belonged to a particular group Thanks.

user2776643
  • 23
  • 1
  • 9

2 Answers2

0

If you are using the default authentication features in AEM (like Geometrixx), which rely on users that exist in AEM, you can use Closed User Groups. CUG allows you to set what users or groups can or cannot see a specific page. You can see where to set CUGs in the page properties dialog for each page. I'm pretty sure CUG settings inherit down the page hierarchy as well.

Using the JCR permissions for this is a good deal more complex, because it's such a low-level architectural thing. However, for more complex solutions, sometimes it's a necessary part of the equation.

ryanlunka
  • 236
  • 1
  • 8
  • Thanks for your response.Sorry if I was not clear enough.Yes; I am using the default authentication.I wanted to hide a page from navigation in the default 'list' component. If I use CUG; the users belonging to that group will still be able to see that particular page's link in the list component; and would be asked for login on clicking on that page.I want the link itself to be hidden if the user belonged to a particular group.I achieved it by denying that page's permission to the particular group from the user/group management console. – user2776643 Apr 22 '14 at 07:36
  • Now; if the logged in user is from that group; the page does not appear in the navigation of the list component. Please provide suggestions/feedback/comments. Thanks. – user2776643 Apr 22 '14 at 07:39
0

I agree with ryanluka that going for JCR permissions should be avoided when the problem can be solved by much simpler approach. I modified the list.jsp of the default list component. Extracted the login user's id using Userpropertiesutil; and based on the group; wrote the code in jQuery to remove that particular page's div from list component.

user2776643
  • 23
  • 1
  • 9
  • Hi I am also facing the same issue. I have a handler and I am calling a method of that handler from sightly html component. Now in the handler I want to know the loggedin user's Id but dont know how to. Any idea how I can get that? – samir Feb 01 '16 at 06:18
  • You can get the logged-in user's id using jackrabbit api in your handler class; by adapting resourceResolver to session . Refer this question http://stackoverflow.com/questions/22549502/how-to-get-the-cq5-userinfo-in-java-or-jsp-by-using-jackrabbit – user2776643 Feb 02 '16 at 08:11