Friday, June 13, 2014

[Liferay] Permission Checker : Setting a portlet to be available for Admin only..

In last post, we got all the sites, but everyone can access what we have in front end if we don't take care of Permissions. 

Permission checker comes into the picture.. 


PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker(); 
Boolean isUserAdmin =permissionChecker.isOmniadmin();
if(permissionChecker.isOmniadmin()){
          // Do what you want.. no user other than admin can see this.
}
Imports..
com.liferay.portal.security.permission.PermissionThreadLocal
com.liferay.portal.security.permission.PermissionChecker


That's all we need. 

Enjoy. Now you have all the sites.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.