I'm attempting to develop a portlet for liferay.
How can I get access to the username and password (and other data liferay has) of the user that's currently logged in?
I'd also like to be able to execute some code when users change their password.
I'm attempting to develop a portlet for liferay.
How can I get access to the username and password (and other data liferay has) of the user that's currently logged in?
I'd also like to be able to execute some code when users change their password.
Or you can just use javascript:
There are many nice to haves in the Liferay namespace, take a look at the not so well documented API:
Also, take a look at the web services available under localhost:8080/api/jsonws which you can invoke with a javascript call:
You can get the User ID by calling
getRemoteUser()
in thePortletRequest
object. This is defined by JSR-168 therefore it's cross-portal compatible.Once you have the ID you can fetch the additional informations by calling
getUserById()
(a Liferay specific service). This is something not covered by Portlet API specification, so it locks you to the Liferay.One simple and easy way to get the user in Liferay is PortalUtil.getUser function.
Liferay Specific stuff, here is a code sample to be written in your Portlet Class to retrieve the User:
Alternatively;
Impersonate User:
Liferay has a concept that admins (or persons with the correct set of permissions) can impersonate a particular user of the portal. Through this they can see how the portal looks to that user.
For executing the code when user change their passwords: One approach would be to create a hook plugin and overriding the services by extending the UserLocalServiceWrapper class. Then checking for the password change and executing your code inside the your custom class.
Hope this helps.