Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Marty Becker
layout.show.portlet.access.denied - ???
August 8, 2012 12:59 PM
Answer

Marty Becker

Rank: New Member

Posts: 6

Join Date: August 8, 2012

Recent Posts

I have created a basic web content portlet on a page and given that web content area a permission for a certain role. As usual, when the user that doesn't have that role accesses the page, the message, "You do not have the required permissions to access this content." is displayed in the web content location on the page.

To keep the error message from being displayed, I have added, layout.show.portlet.access.denied=false, to my portal-ext.properties file. I can see when I start my server that the portal-ext.properties file is read. However, with the layout.show.portlet.access.denied set to false, the error message is still displayed.

How can this be? Is there something else I am missing?

Regards,
Marty
Shinn Lok
RE: layout.show.portlet.access.denied - ???
August 8, 2012 1:08 PM
Answer

Shinn Lok

LIFERAY STAFF

Rank: Junior Member

Posts: 89

Join Date: January 14, 2011

Recent Posts

That property is used only if the user doesn't have access to the portlet. The error message that doesn't show when you have it set to false is: "You do not have the roles required to access this portlet." If you don't want "You do not have the required permissions to access this content." to show, you need to do a permission check and hide the portlet when it fails.
Marty Becker
RE: layout.show.portlet.access.denied - ???
August 8, 2012 1:20 PM
Answer

Marty Becker

Rank: New Member

Posts: 6

Join Date: August 8, 2012

Recent Posts

Thank you for your quick reply!

So then, where would I add this logic? In the attached picture, I want the whole Web Content Display that shows the error to disappear and the lower Web Content Display to shift up and takes its place.

Regards,

Marty
Attachment

Attachments: Clipboard02.jpg (65.6k)
Shinn Lok
RE: layout.show.portlet.access.denied - ???
August 8, 2012 2:40 PM
Answer

Shinn Lok

LIFERAY STAFF

Rank: Junior Member

Posts: 89

Join Date: January 14, 2011

Recent Posts

One way you could do it is find where it displays the error and replace it.

/journal_content/view.jsp
1
2    <c:when test="<%= !hasViewPermission %>">
3        <div class="portlet-msg-error">
4            <%= LanguageUtil.get(pageContext, "you-do-not-have-the-required-permissions-to-access-this-content") %>
5        </div>
6    </c:when>

with
 1
 2    <c:when test="<%= !hasViewPermission %>">
 3        <aui:script use="aui-base">
 4            var portlet = A.one('#p_p_id<portlet:namespace />');
 5
 6            if (portlet) {
 7                portlet.hide();
 8            }
 9        </aui:script>
10    </c:when>
Marty Becker
RE: layout.show.portlet.access.denied - ???
August 9, 2012 6:10 AM
Answer

Marty Becker

Rank: New Member

Posts: 6

Join Date: August 8, 2012

Recent Posts

I find this amazing that this situation is not configurable and has to be solved with changing Liferay code.

Setup for what is shown in the above screen shot.

Role A defined.
Role B defined.

Web Content area 1 (top area) is setup with View permission for Role A
Web Content area 2 (bottom area) is setup with View permission for Role B

User X has Role B
User Y has Role A and B

User X accesses the page and sees what is shown in the above screen shot
User Y accesses the page and sees Web Content area 1 and Web Content area 2.

Is there any other way, other than your suggested code, that User X only sees Web Content area 2 and is not shown Web Content area 1 with its error message?

Regards,

Marty
Shinn Lok
RE: layout.show.portlet.access.denied - ???
August 9, 2012 7:36 AM
Answer

Shinn Lok

LIFERAY STAFF

Rank: Junior Member

Posts: 89

Join Date: January 14, 2011

Recent Posts

Well if you don't want to change the code, another way to achieve your goal would be to leverage the layout.show.portlet.access.denied property.

Instead of (or in addition to) setting permissions for the web content, you would set the permissions of the web content display portlet itself.
Marty Becker
RE: layout.show.portlet.access.denied - ???
August 9, 2012 8:01 AM
Answer

Marty Becker

Rank: New Member

Posts: 6

Join Date: August 8, 2012

Recent Posts

Shinn Lok:
Instead of (or in addition to) setting permissions for the web content, you would set the permissions of the web content display portlet itself.


Isn't that what I described above?

The was I setup the permission is: I go to Web Content on the left-side menu of the control panel. That displays a list of various web content that has been created. I then click Actions and then Permissions for the particular web content. I then check the View permission box for the role that I want to have access.

Regards,

Marty
Shinn Lok
RE: layout.show.portlet.access.denied - ???
August 9, 2012 8:19 AM
Answer

Shinn Lok

LIFERAY STAFF

Rank: Junior Member

Posts: 89

Join Date: January 14, 2011

Recent Posts

You are setting the view permissions for the web content but to deny access to the portlet itself you need to change each web content display portlet's permission.

To set, go to the web content display -> options (wrench) -> configuration -> permissions
Marty Becker
RE: layout.show.portlet.access.denied - ???
August 9, 2012 8:45 AM
Answer

Marty Becker

Rank: New Member

Posts: 6

Join Date: August 8, 2012

Recent Posts

OK, I now see the difference between permissions for the content within the portlet and the permissions for the web content portlet itself.

I have reworked my permissions and have the property set, layout.show.portlet.access.denied=false. It is working as I think it should.

Thank you for your time in helping me understand this!

Regards,

Marty