Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying a portlet only when user is logged in

I have a requirement to display a specific portlet only if the user is logged in. My question is what would be the appropriate way to handle this kind of requirement. Should I handle it through code by using

renderRequest.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY, Boolean.FALSE);

Or is this kind of configuration done using portlet's roles or any kind of portal properties?

As per my understanding, this might be handled by adding a role to the portlet, but I am not sure about where and how to set portlet roles.

like image 471
Pranoti Avatar asked Feb 11 '23 11:02

Pranoti


1 Answers

You can simply remove VIEW permission for Portlet for GUEST Role from Portlet Configuration -> Permissions tab.

By this, GUEST user will see error message like : You do not have permission to access this portlet.

If you want to avoid this message you can override portal property layout.show.portlet.access.denied to value false. This will apply to portal level for each portlet.

If you want to hide permission error message specific to portlet, then in portlet.xml you can define init parameter show-portlet-access-denied with value as false.

HTH

like image 144
Pankaj Kathiriya Avatar answered Feb 14 '23 02:02

Pankaj Kathiriya