Custom permission to custom portlet on specific user in liferay
Asked Answered
R

2

1

How can i define custom permisssion to custom portlet for specific user in liferay I used enviroment liferay 6.1.2 ga3 with jboss In my custom portlet deploy/undeploy button but how can i give specific permission to that only admin person can access that function any other can not use that

check this link https://i.sstatic.net/FFQy9.png

Can you please elaborate.

I also check this link for reference

and in jsp page for rendering all the datagrid data render through jeasyui and rest API

Removing Custom Permissions/Actions from a Portlet http://liferayzone.wordpress.com/2013/09/01/liferay-permission-on-custom-portlet/

Raskin answered 19/7, 2014 at 12:14 Comment(0)
J
2

Liferay allows assigning permissions to roles only, you just cannot do it for single users. You have either define a new role or implement this functionality on your own (not using Liferay's permission system).

Just in case if you would come up with this idea, avoid using creating roles for every user - it is a performance killer. People sometimes try do do this in order to get around the limitations of Liferay's permission system - it is a very bad idea!

Jaala answered 20/7, 2014 at 9:38 Comment(5)
Actually i want to do same as i describe just for test purpose rather the issue of this performance.Can you elaborate the way and how can i implemetRaskin
We have also option about that in one jsp portlet rendering page we have to check its admin or not if admin then we show the button else not.So is there any util file in bundle to check that for admin login or not.??Raskin
You can obtain PermissionChecker object from ThemeDisplay and then check isOmniadmin() method which will tell you if user is an administrator. But it is not a good solution, as this is not configurable (you hardcode administrator role in your code). In the following article, it is described how this should be done properly: liferay.com/web/guest/community/wiki/-/wiki/Main/…Ireneirenic
Ext Js is not natively supported. Why don't you use Vaadin?Ireneirenic
its good and work for just jsp but in our jsp datagrid content render through jEasyUi so all the code in java script for rendering.Raskin
F
1

This tutorial can help you:

  1. You need to create a resource-action-mapping XML file, and add a new action-key (plain string)
  2. Put it into /src/main/resources/resource-action (name it as default.xml)
  3. Create a portlet.properties file under /src/main/resources
  4. Add the following line: resource.actions.configs=resource-actions/default.xml

Deploy your portlet, and check your new permission under Roles -> Select role -> Define permissions tab

You can check the user permissions with the permissionChecker on your JSP

  1. You need this import: <%@ taglib prefix="theme" uri="http://liferay.com/tld/theme" %>
  2. Define objects: <theme:defineObjects />
  3. Now you can use the permissionchecker object:

    permissionChecker.hasPermission(scopeGroupId, portletName, scopeGroupId,    permissionName)
    
Filigree answered 23/1, 2015 at 9:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.